# Tag Info

3

You can use Inset (this is what the interactive editor does basically). Example: The variable crop consists of image scaled coordinates in the order {{xmin, xmax}, {ymin, ymax}} In this example, the value ymax is greater than one, which extends the image beyond the boundary of the original plot. myPlot = Plot[x^2, {x, -1, 1}, Frame -> True]; ...

4

I just realized from this Wolfram page that one can crop the "orange box" by Ctrl+dragging one of the orange handles. myPlot = Plot[x^2, {x, -1, 1}, Frame -> True] and obtain This seems to work pretty well for the question that I asked. A programmatic method would be better, but this use of the front end is OK.

3

Use ImageTransformation. Check the documentation for many examples.

12

Simon's answer is wonderful. It might also be interesting to see what can be done with the more-or-less built-in functions. In order to proceed, first create two auxiliary images which are a pure black and white version of the image and a "shadow" edge version. imgSmall = Import["http://i.stack.imgur.com/FcWRt.png"]; img = ImagePad[imgSmall, 10, White]; ...

33

NB: the code is now on GitHub here. The code at the bottom of this answer defines a package, "shadow", with one public function, imaginatively named shadow, which creates drop shadows, and optionally adds simple highlights too. There are quite a few options and ways to use it, so it's probably easiest to describe its usage by examples. First I'll create ...

1

The method you have works quite well, as long as you're careful about the parameters: img = Import["http://i.stack.imgur.com/K60Nl.gif"]; blue = PixelValuePositions[img, {0.580, 0.705, 0.796}]; {h, v} = ImageDimensions[img]; imgD = ConstantArray[0, {h, v}]; Length[Table[imgD[[Sequence @@ blue[[i]]]] = 1, {i, 1, Length[blue]}]]; bluePeople = ...

1

Here is my try. But it seems to work. First you choose a color: In you case the blue you are looking for in RGB is teamcolor={156, 199, 220}; Now we simply look at a distance measure of every color in the image from this one distcolor=Map[Function[{x}, NormalizedSquaredEuclideanDistance[x, teamcolor]], ImageData@img, {2}]; We then apply ...

2

I'm going to assume we aren't really concerned about how fast this runs, or about using it to detect players in several frames of a video -- just this single still image. In this case, the quickest way I can come up with is to convert the white "blobs" in the image into a graph: First, make a matrix from your data: L = {{95.8636, 1120.96}, {1227.08, ...

3

In cases like the one you've at hand, where there are no superposition of "blue" players it's enough to be able to isolate the morphological component for each player in the field and then ask if your centroids are members of the same morphological component. I'll show a way to isolate the players heavily based on nikie's outstanding Martian chronicles ...

6

This tries to "automatically" detect equal width bands (although they can be unequally spaced): i = Import["http://www.agrisera.com/dokument/bibliotek/sample_quality1.jpg"]; mask = FillingTransform[DeleteSmallComponents[ Binarize@ImageMultiply[Erosion[i, 3], EntropyFilter[i, 3]], 1000], 1]; u = ImageMultiply[i, mask]; v = Quiet[Variance /@ ...

10

Here's my go: pic = Import["http://www.agrisera.com/dokument/bibliotek/sample_quality1.jpg"]; Framed[pic] Isolate the picture by deleting rows and columns with mostly white, and reorient for convenience. pic2 = pic // ImageData // {#, Transpose@#} & // Count[#, {1., 1., 1.}]/Length[#] & /@ # & /@ # & // Flatten[Position[#, n_ /; n < ...

6

I won't deal with the speed factor yet, mainly with the pattern recognition. It is usually a lot easier to detect patterns using the edge patterns of an image, so you were in the right track with the morphological components. Using the Schaar 3x3 operators we filter the image so that we can only see the edges: myedges[v_] := ((ImageData@ImageConvolve[#, ...

4

1) How the pixel values are defined in mathematica, does each pixel value in image is weighted by it neighborhood configuration? or how it is different from matlab? A pixel is just a number or a vector inside a 2d matrix. If it is a number, the image is in "Grayscale", if it is a vector like then there are several possibilities. The most used form is ...

5

In your "common sense" interpretation, you are thinking of the $3$-pixel image {1, 0.5, 0} as a function $$1\mapsto1, \quad 2\mapsto0.5, \quad 3\mapsto0$$ on the domain $[1,3]$. When you resize to a $5$-pixel image, you map $[1,5]$ to this domain and sample the interpolated function. Hypothesis: You should instead consider the domain to be $[0,3]$, ...

0

If you look at a somewhat larger "image" you can see that the end points are being treated specially: n = 4 Show[{ Plot[ 36(x - 2)/5 + 1/12 , {x, 1, 9}], ListPlot[ ImageData[ ImageResize[Image[{Range[0, 1, 1/n]}], {2 n + 1, 1}, Resampling -> "Bilinear"]][[1]], PlotStyle -> {PointSize -> .02}]}, PlotRange -> All] ...

2

Well,you can find out the coeffs that Mathematica is using. I haven't tried to find a closed formula for general dimensions, but it doesn't seem too hard. fromdim = 5; todim = 10; s = {#, Chop@ImageData[ ImageResize[Image[{#}], {todim, 1}, Resampling -> "Bilinear"]]} & /@ Tuples[{0., 1.}, fromdim]; coeff = Solve[And @@@ ...

4

ImageDifference[] is ideal for such a task: i = ColorNegate@Import["http://i.stack.imgur.com/Eskg5.png"]; ImageDifference[DeleteSmallComponents[i, 30, CornerNeighbors -> False], i]

5

Using TopHatTransform: img = Import["http://i.stack.imgur.com/TlMUh.png"]; TopHatTransform[img, DiskMatrix[5]] Since you ask this kind of basic image processing question, I guess a good idea would be to read about morphological operations. A very nice practical book is the legendary Digital Image Processing by Gonzales & Woods. There you will learn ...

4

For this purpose you can use the function Colorize which is sufficient even for fancy coloring. Let's make some examples with a B&W photo img = Import["http://i.stack.imgur.com/397vv.png"] If you simply want to use the gray channel as one or more color channels you use Colorize[img, ColorFunction -> Function[gray, RGBColor[0, gray, gray]]] ...

0

rotate the image by some degree and calculate the correlation of both images. it should be small for uncentered circles and large when many points overlap. repeat for as many degrees as you need to be sure.

1

If you have a worksheet like this one: You could do: id = Import["C:\\test.xlsx"]; ColorCombine[Image /@ ({#, # 0, # 0} &@id[[1]])] Note for wicked users:Yes, I always store my photos in Excel.

0

There are many functions that generate RGBColor[r,g,b] and these can often be helpful even for purposes such as this. Blend figures out the correct red, green, and blue components and then I extract them using a rule, putting them into the required format {r,g,b}. Another thing worth noting is that I use an anonymous function that I give that property ...

4

Here's one way: data = RandomReal[{0, 1}, {100, 100}]; ColorCombine[{Image[data], Image[0 data], Image[0 data]}] This creates an RGB image which has the data as the Red channel, and all zeros in the Green and Blue channels. By weighting them differently you can get any color you wish. For instance, you can get yellow: ColorCombine[{Image[data], ...

8

You're close: You can use ComponentMeasurements to calculate measurements for each component. (The same measurements that you can use in SelectComponents, too). If you can get away with the center of mass of the marked pixels, it'really quite simple: imga = Import["http://i.stack.imgur.com/moV5x.png"]; binary = MorphologicalComponents[ ...

5

i = Import["http://i.stack.imgur.com/agPO0.png"]; (mc = MorphologicalComponents[ColorNegate[i], CornerNeighbors -> False]) // Colorize Grid@Partition[ Image /@ (Replace[mc, Except[#] -> 0, {2}] & /@ Range@Max@mc), 4]

3

If you use a DistanceFunction where a complete contour always falls on the pixels, like ManhattenDistance you can directly work on the image. The approach is pretty simple, calculate the distance transform horse = Import["http://i.stack.imgur.com/KCfWy.png"]; dist = DistanceTransform[horse, DistanceFunction -> ManhattanDistance]; And then you set all ...

2

Your image is taken from DistanceTransform documentation page. pic2 = ListContourPlot[ImageData[pic, DataReversed -> True], ContourShading -> None, Frame -> False, ContourStyle -> Yellow]; Show[ pic, pic2]

3

If you have both Mathematica and MATLAB (with the Image Processing Toolbox, of course) installed on the same computer, an easy way would be to use MATLAB to read the file, and then pass the data to Mathematica using MATLink. This would avoid the need for you (or someone else) to write C code as a LibraryLink program, which (judging from the description of ...

1

Here's a quick-n-dirty example, hand-tweaked values. You'll probably want to use more sophisticated means if you have more than a few images to process. You can also use the drawing tools to take your image and manually draw a mask. Many ways to skin this cat... mask = 1 - BoxMatrix[ Sequence @@ Reverse@({2, .8} Round[ImageDimensions[foto17]*.5])]; ...

4

Yes! I have done this before with RAW files. Use the dcraw command line utility and convert the RAW file to a TIFF. You'll need to use appropriate command line options to prevent any processing of the data. dcraw -o 0 -D -T -6 infile.cr2 It'll output a TIFF file with un-demosaiced raw sensor data. You can read that with Mathematica. EXIF data can be ...

4

You could create your own filter, using DiskMatrix embedded into a zero matrix the size of the image, and then apply your filter with the resulting mask, iteratively "rolling" the disk insert. Probably not very efficient compared to using such an algorithm in an image-processing program where it's coded/compiled at low level. Nonetheless, there are tons of ...

4

This is how I did it: (* These can be compounded into one expression *) img = Binarize[Import["http://i.stack.imgur.com/EY2EG.png"], 0.2]; img = DeleteSmallComponents[img, 20]; img = DeleteBorderComponents@ImageCrop@img; m = MorphologicalComponents[img]; (* Identify circles versus rectangles using Eccentricity *) {rectangles, circles} = ...

2

One way to proceed is to binarize the image and find the constituent components: img = Import["http://i.stack.imgur.com/EY2EG.png"]; objects = MorphologicalComponents[Binarize[img, 0.21]]; Colorize[objects] Examine the various components (that are colored differently) ComponentMeasurements[objects, "Area"] {1 -> 133874., 2 -> 3085.75, 3 -> ...

6

This is based on a reading of that paper. It's a ways from my areas and I do not claim to get it correct, but the code might be of use in any case. Import the image. im = Import["http://i.stack.imgur.com/POS2E.jpg"] Get the basic data. imat = ImageData[im]; idims = ImageDimensions[im]; Prepare a kernel matrix to convolve with. I start with a disk. ...

Top 50 recent answers are included