New answers tagged image-processing
6
Here's another approach that uses some of the built-in morphological (image processing) functions. Begin by reading in the figure, detecting the edges, and then making them thick:
i = Import["http://dailycoffeenews.com/wp-content/uploads/2011/09/disposable-coffee-cup.jpeg"];
fat = Dilation[EdgeDetect[i], 20]
Get just the outline of the cup:
thin = ...
11
Too late and not so general as @Nikie but I will still like to answer in order to highlight a method involving generalized Eigen values! Lets take the image.
img = Import["http://i.stack.imgur.com/H63BK.jpg"];
(* Detecting ellipsoidal edges and removing the straight line component *)
i = ImageSubtract @@ {EdgeDetect[img, 10],EdgeDetect[img, 10, ...
23
Basically, you want to fit a shape to a set of points with outliers. One common algorithm to do this is RANSAC (random sample consensus). The basic outline of this algorithm is:
Select N points at random (where N is the minimum number of points required for fitting the shape, i.e. 2 for a line, 3 for a circle and so on)
Fit the shape to these points
Repeat ...
7
This didn't work as well as I'd hoped, but it's quite interesting to see what went wrong.
i = Import["http://dailycoffeenews.com/wp-content/uploads/2011/09/disposable-coffee-cup.jpeg"];
j = ColorConvert[i, "GrayScale"];
k = Thinning[
DeleteBorderComponents[
DeleteSmallComponents[
Opening[
Dilation[
...
1
It's a shame there is no raw data to work with, since this is an interesting problem but quantization, resampling and jpeg compression have probably wiped out any subtle features that may have been present.
I think the basic idea outlined in the question is workable. The proposal is to high-pass filter each column of the image by fitting a polynomial with ...
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}, ...
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}}]}]
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.
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\
...
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 ...
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]]});
...
1
Here is a trivial text recognizer based on the input samples you've given, it might act as a template for a more customized solution for you.
It may be that you want a more generic solution, in which case you can increase the number of training templates, or abstract a generalized model of the characters that you are interested in.
(* Import example ...
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 ...
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 ...
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 ...
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 ...
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 ...
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,
...
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 /@ ...
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]
1
Graphics3D[MapThread[{RGBColor @@ #1, Sphere[#2, 1]} &,
{{{0.529412, 0.529412, 0.529412}, {0.647059, 0.647059, 0.647059}},
{{0, 10, 0}, {20, 30, 0}}}], Lighting -> "Neutral"]
But, if you can, why not stick to two dimensions?
Graphics[MapThread[{RGBColor @@ #1, Disk[Most[#2], 1]} &,
...
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 ...
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 ...
10
tp = ExampleData[{"TestImage", "Lena"}];
Manipulate[Column @ {tp, ImageValue[tp, p]}, {{p, {1, 1}}, Locator}]
9
As a side-note - you can quickly get color info from images using image assistant. Just click once on the image and in version 9 assistant will appear below:
10
For example:
tp = ExampleData[{"TestImage", "Airplane"}];
Manipulate[Column@{tp, Extract[ImageData[tp], Round /@ p]},
{{p, {1, 1}}, Locator}]
3
With ImageData[]. Like this:
MatrixPlot@ImageData@EdgeDetect@ExampleData[{"TestImage", "Lena"}]
2
or maybe you don't want to put it on the image, but somewhere near it
use this :
Column[
{Button["Transform", CreateDialog[ImageHistogram[img]]], Show[
img]]
Which works exactly the same but looks a little different.
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]],
...
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 -> ...
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}]
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):
...
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
The problem is that Do doesn't return anything so you just need to prepend Print to your function to see the result:
Do[Print@ColorNegate[ToExpression[StringJoin["name", ToString[i]]]], {i, 14, 20}]
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,
...
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 ...
Top 50 recent answers are included



