Tag Info

Hot answers tagged

30

EDIT: I've found a bug in the code; Now the result looks a lot better, too. This isn't perfect, but it's a start. The first step is to find the "chain elements" (what are those anyway? I'm guessing cells?) The chain elements have a distinctive scale, so I can filter them out easily using a median filter: Subtracting the median filtered image from the ...


14

This may be what you are looking for. img = Import["http://i.imgur.com/Wd9lPRa.jpg"] Now use DominantColors. Graphics[{#, Disk[]}] & /@ DominantColors[img, 4]


12

Another potentially useful command of this kind is the CommonestFilter which looks locally about each pixel and chooses the most common value to display. Setting the neighborhood large causes large regions of constant color. For example img = Import["http://i.imgur.com/Wd9lPRa.jpg"] CommonestFilter[img, n] where img is the image from the OPs question ...


11

ImageForwardTransformation[] is the function you want here. To give a concrete example, here's how an image might be transformed by the complex mapping $w=z^3$: img = ExampleData[{"TestImage", "Mandrill"}]; imgc = ImageForwardTransformation[img, Through[{Re, Im}[(#[[1]] + I #[[2]])^3]] &, Background -> 1, ...


10

For those without v9, here's another attempt based on FindClusters, but using a different colour space. The idea is to reduce the effect of overall brightness on the "distance" between colours, so that the clustering gives more weight to differences of hue and is less likely to pick out different shades of gray. newspace[{r_, g_, b_}] := {r - g, b - g, (r + ...


9

Try use DominantColors on particular selections instead of the whole. After import select regions you want to analyze and copy that (optionally) multiple selections as a list of images. (New in 9?) img = Import["http://oaadonline.oxfordlearnersdictionaries.com" <> "/media/oaad8/fullsize/f/fru/fruit/fruit_fruit.jpg"] Paste it and apply dominants ...


9

This now has been discussed in Wolfram blog post by Michael Trott: Making Formulas… for Everything—From Pi to the Pink Panther to Sir Isaac Newton Here is one of the example apps from blog - go read it in full - fun! Don't miss the link to download the notebook with complete code and apps at the end of the blog.


8

k = Import["traffic.avi", "ImageList"]; a = RandomReal[{0, 1}, 10]; s[n_] := ListLinePlot[a[[1 ;; n]], PlotStyle ->{Thick, White}, PlotRange ->{{1, 10}, {0, 1}}] Table[ImageCompose[k[[n]], s[n]], {n, 10}]


8

Also worth noting is that there's a companion function to ImageValue, called PixelValue. The difference between the two is, as far as I can tell from the documentation, that ImageValue interpolates the color of a coordinate according to the colors of nearby pixels, whereas PixelValue finds the color of the pixel whose centre is nearest to the integer values ...


8

You might also enjoy playing with ColorQuantize, which reduces the number of colors used in an image. Here's a BarChart of the results of quantization: colorquantized = SortBy[ Tally[ Flatten[ImageData[ColorQuantize[img, 12, Dithering -> False]], 1]], Last]; BarChart[colorquantized[[All, 2]], ChartStyle -> RGBColor /@ ...


7

Here's another take. Not that successful though. It might have educational value. i = Import@"http://i.imgur.com/Wd9lPRa.jpg"; Extract pixel values into a list of length 9k+. data = Flatten[ImageData[i], 1]; Dimensions@data {9603, 3} Show the pixels as 3D points with (x, y, z) for (R, G, B) components. Table[Graphics3D[todraw, Axes -> True, ...


6

ImageValuePositions, new in 9, can return a list of white pixel positions. i = Import@"http://i.stack.imgur.com/opzqB.png"; p = ImageValuePositions[i, White] // Mean (* {298.896, 21.3231} *) HighlightImage[i, {p}, Method -> {"CrossMarkers", 5}] Update: Surrounding rectangle Get the min/max of white pixel coordinates. whites = ImageValuePositions[i, ...


6

For another approach, there's always the ComponentMeasurements way: cm = ComponentMeasurements[Dilation[i, BoxMatrix[5]] , "Centroid"] {1 -> {297.633, 23.7345}} mean = Mean@cm[[All, 2]] (* not needed if only one component found*) HighlightImage[i, List@mean, Method -> {"DiskMarkers", 3}, HighlightColor -> Green] I'm not happy with ...


6

Suppose your original image is img. First we Binarize it: imgBinarized = img // Binarize; Then crop all the black boarders: imgConcerned = ImageCrop[imgBinarized] So now, using the HitMissTransform (also wiki page), we can easily get its center position: centerPos = HitMissTransform[imgBinarized, ImageData[imgConcerned]] To achieve the ...


5

I present a solution qualitatively similar to belisarius's, but done somewhat differently: (* import an AVI frame-by-frame *) imgs = ExampleData /@ ExampleData[{"TestAnimation", "ToyVehicles"}, "Frames"]; (* some plots *) plots = Table[Plot[Sin[x], {x, -$MachineEpsilon, u}, Axes -> None, Frame -> True, Epilog -> ...


5

Setting img to the result of downloading and importing your image, img = Import["http://i.stack.imgur.com/ZObmf.jpg"] rasImg = Rasterize[img, RasterSize -> 100]; edges4 = EdgeDetect[rasImg, 2, 0.030, "StraightEdges" -> 0.14] imgLines4Sep1 = ImageLines[edges4, 0.05, 0.01]; Graphics[Line /@ imgLines4Sep1] yields a picture featuring at least some ...


5

Not too hard. a = Image[Table[If[EvenQ[x + y], 1, 0], {x, 50}, {y, 50}], ImageSize -> Large]; Graphics[{Texture[a], Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}, VertexTextureCoordinates -> {{1, 0}, {0.5, 1}, {0, 0}}]}]


4

To get a rolling plot you can change the PlotRange with time, something like this: (* fake movie frames *) image[t_] := RandomImage[{0, 1}, {150, 150}]~Blur~3 (* make up some data to plot *) data = Accumulate[RandomReal[{-1, 1}, {100}]]; range = {Min[data], Max[data]}; (* define the rolling plot *) rollingplot[t_, n_] := ListLinePlot[data[[;; t]], ...


4

A variation of BoLe's center-of-gravity method for version 7: img = Import["http://i.stack.imgur.com/opzqB.png"] SparseArray[ImageData@Binarize@img]["NonzeroPositions"] // Mean // N {30.1769, 299.396} Output in (y,x) order. SparseArray is much faster than Position: dat = ImageData@Binarize@img; Do[SparseArray[dat]["NonzeroPositions"], {1500}] // ...


4

If you import the avi using the option GraphicsList then you immediately have a variable which is a list with all the frames. For instance: imagelist = Import["...file.avi","GraphicsList"] You can then create an animation with this imagelist and superpose the frame numbers (or whatever other numbers you want using Show inside the Animate function): ...


4

If the problem is that the transformation function is slow to compute, a simple way to create and use a look-up table is to memoize the function: (* create an example image *) image = RandomImage[1, {30, 20}, ColorSpace -> "RGB"] ~ ImageResize ~ Scaled[10] (* define the transformation function with memoization *) mem : func[{x_, y_}] := mem = {x + 0.01 ...


3

Lets do an exercise importing and exporting JPEG data. First let's create a tiny single pixel JPEG file: In[1]:= Export["~/Desktop/minitest.jpg", Image[{{0}}]] Now lets import the binary data that we have just created: In[2]:= Import["/Users/gdelfino/Desktop/minitest.jpg", "Binary"] Out[2]:= {255, 216, 255, 224, 0, 16, 74, 70, 73, 70, 0, 1, 1, 1, 0, 72, ...


3

Your binarydata seems to be a string with hexadecimal digits. Converting this using FromCharacterCode yields nonsense, of course. It can be solved in a few steps: 0) The string: imageString = "FFD8FFE000104A46494600010201006000600000FFEE000E41646F6265006400000\ 00001FFE1135D4578696600004D4D002A0000000800070132000200000014000000620\ ...


3

ImageTransformation works with functions, not tables. It should be straightforward to define a function that carries out the same transformation as the table, but you will need to be aware that the #[[1]] and #[[2]] arguments go from 0 to 1 (across the image) so you will need to design the function to handle this input range. For example, you might want a ...


3

Here's one way that exploits the fact that you have a constant black background. If your image is called img, then small = ImageCrop[img] crops it and leaves just the central rectangle. Now you want the center of the cropped image, which can be found cen = ImageDimensions[ImageCrop[img]]/2 To display the small image and the centerpoint: ...


3

Might be better to use Table[] instead, so you can still use the processed images later: girls = Table[ImageEffect[ExampleData[{"TestImage", img}], "Charcoal"], {img, {"Elaine", "Lena", "Tiffany"}}] so for instance girls[[2]] gives Lenna in charcoal. For your specific example, Table[ColorNegate[ToExpression["name" <> ToString[i]]], ...


2

Here's a simple answer that uses the built-in image filtering operation along with a customized thresholding. The idea of the adaptive thresholding is that in each neighborhood, the value of the current pixel is compared to the Mean throughout the neighborhood: if the pixel is larger than a given percentage of that Mean, then set it to 1, otherwise set it to ...


2

To search only for lines at given angles, say between theta0 and theta1, you could: Compute the Hough transform using Radon[img, dims, {theta0, theta1}, Method -> "Hough"] Detect peaks in the Hough transform, ie. the local maxima with high values (MaxDetect and Binarize may help, for example) Extract the positions of the detected peaks and convert them ...


2

To prevent interpolation between adjacent pixels requires the option Resampling -> "Nearest" in ImageResize. This is the default setting for images smaller than $24\times24$ pixels, but larger images will use one of the other resampling methods (I'm not sure which). The desired result can therefore be obtained with: img = ImageResize[img, {8152,512}, ...


2

I think you have to make sure that your transformation function always handles input cleanly. Here's a test you can do to see what goes into your function. (And I think you can use real coordinates if you use the DataRange option.) i = ImageResize[ExampleData[{"TestImage", "Mandrill"}], {20, 20}]; The function: f[pt_] := (Print[pt]; {pt[[1]], pt[[2]]}); ...



Only top voted, non community-wiki answers of a minimum length are eligible