Tag Info

New answers tagged

9

Do you see an error message in the Messages window? When this happens (the result of an evaluation is more or less the expression you entered), it's usually because it can't be evaluated, e.g. because image2 is not actually an image. If I Import the image from your post, ColorReplace accepts it as an argument, but since the blue you're trying to replace ...


8

Use Erosion[image, DiskMatrix[radius]]: img = Import["http://i.stack.imgur.com/WVmnm.jpg"]; Erosion[img, DiskMatrix[2]] Intuitively, you can imagine that this places a disk with radius 2 at every black pixel. If you're more concerned about speed than accuracy, you can also use Erosion[image, radius] which places a square with some radius at every black ...


2

Take a look at ComponentMeasurements[], in particular: ComponentMeasurements[..., "Centroid"]; This will give you a list of the centroids in the form {1 -> {x1, y1}, 2 -> {x2, y2}, ...} Update As pointed out by nikie in a comment, Also, ComponentMeasurements takes a 3rd parameter crit, that basically does the same as SelectComponents last ...


9

img=Import["http://i.stack.imgur.com/uBeKs.png"] mg = MorphologicalGraph[img] vdF = With[{gr = #}, VertexDelete[gr, _?(VertexDegree[gr, #] <= 1 &)]] &; Nest[vdF, mg, 2]


6

First, here's an image from the docs which we'll use for testing: img = Import["http://i.stack.imgur.com/bzkJM.png"] Going with the definition given in the IPP, here is a remapping method based on the use of ImageValue[]: Options[ImageRemap] = {Padding -> 0, Resampling -> "Bilinear"}; ImageRemap[img_Image, xm_?MatrixQ, ym_?MatrixQ, opts : ...


3

Assuming that there is a linear relation between rows & columns and the UTM coordinates, one could do the following: Find the rows and columns of the coordinate lines via marginal distributions: {dimX,dimY} = ImageDimensions[img]; distX = Total[ImageData[ColorConvert[img, "Grayscale"]]]/dimY; distY = Total[ImageData[ColorConvert[img, "Grayscale"]], ...


13

I take a screenshot of your image and assign it to the image variable. In[2]:= ImageDimensions[image] Out[2]= {1326, 1150} This computes the positions of the lines in your image: In[3]:= lines = ImageLines[Binarize[ColorDistance[image, Gray], {0, .4}]] Out[3]= {{{0., 638.044}, {1326., 638.044}}, {{0., 132.694}, {1326., 132.694}}, {{0., 891.219}, {1326., ...


11

I tried the FFT idea just to see what it looks like. Here is a very quick and dirty version t = 80; fft = Table[Fourier[img[[All, All, x]]], {x, 1, 3}]; fft[[All, t ;; 1356 - t, All]] = 0; fft[[All, All, t ;; 2048 - t]] = 0; red = Image[Re[InverseFourier[fft[[1, All, All]]]]]; green = Image[Re[InverseFourier[fft[[2, All, All]]]]]; blue = ...


9

Orientation is not part of the image itself; it is stored as metadata. In version 10.1 at least it seems that this data is respected. One can also read this value using the Import element "CameraTopOrientation": Import["file.jpg", {"JPEG", "CameraTopOrientation"}] Right A numeric value can be read from "Exif": "Orientation" /. Import["file.jpg", ...


12

The result you want looks very close to a spanning tree - which can be found very fast. Maybe it needs some refinement, but I think it's a good first step. Step 1: Find endpoints img = Binarize@ ImageTake[ Import["http://i.stack.imgur.com/AdAT8.png"], {1, -1}, {1, 230}] (* end points are points that are on one of the lines and have \ exactly 2 white ...


47

Here's a crude first attempt: First find the mosquito grid using RidgeFilter img = Import["http://i.stack.imgur.com/XroGQ.jpg"]; ridges = ImageAdjust[ColorConvert[RidgeFilter[img, 2], "Grayscale"]] (Note that I'm using ColorConvert after RidgeFilter, so RidgeFilter can find ridges in all color channels. Since RidgeFilter is nonlinear, the order makes a ...


7

Mathematica 10.2 introduced the function ColorBalance, which can be used to correct the white balance of an image. 1) Example Photos Original Photos imgList = Import /@ {"http://i.imgur.com/qzFttRD.jpg", "http://i.imgur.com/fh9tAK1.jpg", "http://i.imgur.com/b2kWM3y.jpg", "http://i.imgur.com/amNRIhh.jpg"}; ImageAssemble@imgList Balance that ...


1

You may want to do some processing on the image before your Binarize it. Working with the Blue channel of your jpg: img = ColorSeparate[Import["tRGTt.jpg", "JPG"]][[2]]; Use a BottomHatTransform to correct the background img2 = Binarize[BottomHatTransform[img, DiskMatrix[15]]] There are many ComponentMeasurements options you can play with to be ...


4

I'm not sure how you get your FFT image. If I apply a discrete Fourier transform to your image: img = Import["http://i.stack.imgur.com/lquy0.jpg"]; pixels = ImageData[img][[All, All, 2]]; pixels = pixels - Mean[Flatten@pixels]; (Setting the data to 0 mean removes the bright spot in the center of the FFT - the bin for frequency 0.) wnd1d = ...


4

Click on your figure. Then a set of graphics tools will appear beneath your figure. Use the Coordinates Tool. One by one, click on the corners of the region you seek. Then use the window below to Copy Coordinates. Here the ones I get for the front W face of your figure: {{72.5`, 507.5`}, {70.5`, 158.5`}, {135.5`, 140.5`}, {136.5`, 484.5`}, {209.5`, ...


17

As I've written in a previous answer, I would start by searching for the white centers: img = Import["http://i.stack.imgur.com/LaMAg.jpg"]; img = ColorConvert[img, "Grayscale"]; components = ComponentMeasurements[ MorphologicalBinarize[Closing[img, DiskMatrix[5]]], {"Centroid", "Circularity", "EquivalentDiskRadius", "Mask"}, #2 > 0.65 &]; ...


9

First of all, when I run your code to produce particles1 I do not get the same result that you show, but maybe this is a version difference. I'll use this image as the starting point: Now, the problem, as you correctly identified, is that you have some overlap between particles. However, the overlap is small, and you can easily identify which colors you ...


1

With the frames being frames = Binarize /@ (Graphics[{White, Rectangle[{-2, -2}, {2, 2}], Black, Rectangle[{-0.5, -0.5}], Disk[#, 0.1]}, Background -> White] &) /@ CirclePoints[1.5, 150][[;; 10]]; ImageAssemble@frames One can just add up all frames, as White (1) + Black (0) will become White (1) and White (1) + White (1) ...


8

One simple way to get a robust background image even if the dots overlap from one frame to the next is to use the per-pixel median: frames = Table[ Rasterize@ Graphics[{Opacity[0], Rectangle[{-1.1, -1.1}, {1.1, 1.1}], Opacity[1], Rectangle[{-.5, -.5}], Disk[{Cos[p], Sin[p]}, .1]}], {p, 0, Pi/5, Pi/50}]; background = ...


6

Essentially you want to find all pixels that are black in all images. I turned the color around so that the goal became to find the pixels that are white in all images. Now 0x0=0, 1x0=0 and 1x1=1, so what I would propose is to multiply all images in the animation with each other. Afterwards I use ColorNegate to get back your configuration with a white ...


3

If your background is constant then this will suffice: With[{bg = ImageAdd[ImageSubtract[frames[[1]], frames[[2]]], frames[[2]]]}, ColorNegate@ImageSubtract[bg, #] & /@ frames]


3

Here's an approach that works on your example image sequence: frames = Table[ Rasterize@ Graphics[{Opacity[0], Rectangle[{-1.1, -1.1}, {1.1, 1.1}], Opacity[1], Rectangle[{-.5, -.5}], Disk[{Cos[p], Sin[p]}, .1]}], {p, 0, 2 Pi, Pi/2}]; masks = ImageDifference @@@ Partition[frames, 2, 1]; MapThread[ ColorNegate@ImageMultiply[##] &, ...


1

You can use ColorReplace: image = Import["http://i.stack.imgur.com/Pgppv.png"]; dx = 40; dy = 40; redblack = ColorReplace[image, {Red -> White, Black -> White, _ -> Black}]; box = BoxMatrix[Floor[{dx, dy}/2]]; ImageAdjust[ImageConvolve[redblack, box]]


4

As long as you're only counting/summing pixel values in a sliding window, you don't have to recalculate the whole sum for every pixel. You can just "count" red/black pixels in a "1x1 window" and then use a moving average or "box" filter to sum over neighborhoods. First calculate two images where every red/black pixel is 1, other pixels 0: image = ...


4

As suggested by Rahul, LocalAdaptiveBinarize is your friend: LocalAdaptiveBinarize[pic, 15] In order to count things, you can use the MorphologicalComponents command. Here we colorize it to get a visualization of how well the morphological processing segments the data: MorphologicalComponents[LocalAdaptiveBinarize[pic, 15]] // Colorize Of course, ...


3

This answer is effectively a generalization of the approach by halirutan and Pickett. Here, I present a function that when given a list of colors, a list of positions and colors, or a color gradient known to ColorData[], it yields a listable compiled function effectively equivalent to Blend[]: makeCompiledBlend[colors : (_String | _List), opts___] := ...



Top 50 recent answers are included