Tag Info

Hot answers tagged

10

Simple enough, and fails only on one scarcely populated column. Easily fixed if you enforce the "monospaced" property i = Binarize@Import@"http://i.stack.imgur.com/XWhHv.png"; (* delete noisy border*) i1 = DeleteSmallComponents[ImageTake[i, {1, 1650}, {30, -1}], 10]; id = ImageDimensions@i1; cm = ComponentMeasurements[i1, "Centroid"][[All, 2]]; bb = ...


9

Plain old ImageAdjust will improve it quite a lot, though you have to chop off the bright orange text to stop the algorithm being fooled: ImageAdjust[img ~ImageTake~ 2100] You could now bring out the colours a bit more with a boost to the contrast of the saturation channel: ColorCombine[MapAt[ImageAdjust[#, {0, 2, 1}] &, ColorSeparate[%, "HSB"], ...


9

Another approach is to try and histogram equalize the image to something similar, but with more pronounced colors. I found this picture at google images img = Import["http://i.stack.imgur.com/ogkEu.jpg"]; img2=Import["http://i.stack.imgur.com/vEkvx.jpg"]; Then the desired picture can take on (something of) the coloration of the new image using ...


9

There appears to be insufficient data in the provided image. Boosting saturation by a factor of ten: img = Import["http://i.stack.imgur.com/ogkEu.jpg"]; hsb = ColorConvert[img, "HSB"]; ImageApply[# {1, 10, 1} &, hsb]


9

All three parts of this operation can be done in 0.026 seconds: In[3]:= AbsoluteTiming[ImageAdd[img, Binarize[img = Import[filename, "PNG"], {50/255, 1}]];] Out[3]= {0.026024, Null} PixelValuePositions can be used for extracting pixel positions: In[1]:= img = Import["http://i.stack.imgur.com/uye1v.png"]; AbsoluteTiming[bimg = Binarize[img, {50/255, 1}];] ...


6

Nice Problem. Perhaps something like: f[x_] := List @@ (ColorData["TemperatureMap"][x]); s = Table[(f@x) -> x, {x, 0, 1, .001}]; k = Nearest@s; Usage: c = DensityPlot[#, {x, 0, 1}, {y, 0, 1}, ColorFunction -> "TemperatureMap", Frame -> None, PlotRangePadding -> 0, PlotPoints -> 100] & /@ {x, y}; m = Map[k, (List @@@ ...


6

This one takes less than one third of the time in my machine. The main idea is NOT converting to ImageData[] to speed up image ops. imgs = Import /@ fNames; fun[img_, idx_] := ImageApply[UnitStep[# - .18]/number idx &, img]; imgs1 = MapIndexed[fun[#1, #2[[1]]] &, imgs]; fold = Fold[ ImageAdd[ImageSubtract[#1, ImageMultiply[#1, Binarize[#2, 0]]], ...


6

Using the images in the duplicate question, grey = Import["hstbasils.jpg"]; colour = Import["St.-Basils-Cathedral-001.jpg"]; {grey, colour} transform = Last@FindGeometricTransform[colour, grey]; tcolour = ImageTransformation[colour, transform, DataRange -> Full, PlotRange -> Transpose@{{0, 0}, ImageDimensions@grey}]; ...


5

This seems quicker. Importing the images is the slowest bit, there's probably not much you can do about that. fNames = FileNames["*.png"]; n = Length @ fNames; bins = Table[ Clip[Import[fNames[[i]], "GrayLevels"], {0.18, 0.18}, {0, i/n}] , {i, n}]; Colorize[ Image[Map[Max, Transpose[bins, {3, 1, 2}], {2}]], ColorFunction -> "TemperatureMap"]


4

We focus on retrieving pixel positions meeting a criteria using Yves Klett and Simon Wood's answer. Let's run a test case using pixel values of 1 (this can easily be generalised to conditions such as pixel value >= 50). First generate some random coordinates in a 900 x 900 image. xc = RandomSample[Range[900], 500]; yc = RandomSample[Range[900], 500]; Then ...


4

Here is one approach that does not respect object boundaries that uses HistogramTransform` in the HSB color space. For example, you can colorize the black and white image imgBW (according to the colors in the reference image img) using: img = ...


4

Yes, you can use ImageApply. For example, if img1 and img2 are two images of the same size, then ImageApply[Max, {img1, img2}] takes the max of each channel.


4

You can also use ColorCombine: When combining a color image with a grayscale image, ColorCombine creates an image of the same color space with alpha channel. f1 = With[{dt = #, max = Last@Dimensions[#]}, ColorCombine[ {Image[MapIndexed[List @@ ColorData[{"Rainbow", {1, max}}][Last@#2] &, dt,{2}]], Image[dt]}, "RGB"]] &; data = ...


4

data = RandomReal[1, {30, 30}]; ImageMultiply[LinearGradientImage[{Blue, Red}, {30, 30}], Image[data]]


3

It's a little hard to be sure this is exactly what you are looking for, but at least it's a start. First, make the gradient image: rainbowImg=Image[Colorize[Image[Rescale[Table[j, {i, 1, 100}, {j, 1, 100}]]], ColorFunction -> "Rainbow"]] Then take the data image and use it as an alpha channel to allow it to specify the brightness of the resulting ...


3

I finally found a solution: mask = (* As seen above, copied from masking tool as a "Image *) pos = Position[mask // ImageData, 1]; spectra = Extract[img, pos];


3

I guess the crucial point in your question is how to combine the images. When I look at the IDL output image, I guess that what IDL does is to assume that black is transparent when combining two images. It looks to me as if the red points are completely drawn over other colors which suggests that this was the last image layer that was added. Let me give a ...


3

As for part three of your operation, this seems to be rather zippy (about 800x faster than the ReplacePart line alone, with the additional benefit of shedding the Position part): img = Clip[imgData, {0, 49}, {0, 255}];


2

One way to speed things up is to get the ImageData and work with that directly. A simple rule can give you your result: Image[ImageData@bin /. {1 -> {1, 0, 0}, 0 -> {0, 0, 0}}] This takes 0.1 seconds on my computer compared to 2 seconds for the ReplacePixelValue version. Yes there is a difference between ReplaceImageValue and ReplacePixelValue. ...


2

To find a good binarization value, you can quickly scan through all the values. It's very quick. img = Import["http://i.stack.imgur.com/natsI.png"] Manipulate[Binarize[img, t], {t, 0, 1}] You can make it red this way: z = ImageMultiply[img, 0]; Manipulate[ColorCombine[{Binarize[img, t], z, z}], {t, 0, 1}]


2

The main culprit for the slowness is the presence of a couple of lines like this in the internal implementation of ReplacePixelValue: coords = DeleteDuplicates[coords, {}]; I have not seen this usage of an empty list in the second argument of DeleteDuplicates and have no idea what it is supposed to do. It is very slow though. If we temporarily redefine ...


2

Here is a revision that (maybe) combines things as you ask. The SetAlphaChannel command makes the black pixels clear in each of the images. Now you can combine the images directly using Show, and the order of precedence in the colors is given by the order in which they appear in the Show command. rchan = Import["http://i.stack.imgur.com/ruNFL.png"]; gchan = ...


1

You could make a mask like this: i = Import@"http://i.stack.imgur.com/Gmpar.png"; mask = Closing[SelectComponents[MorphologicalBinarize@i,"Area",# > Times@@ImageDimensions@i/2 &], 2]; gs = ColorConvert[ImageMultiply[i, mask], "Grayscale"] And then (I still don't understand why you want to do it, but anyway), you could perform any arithmetic ...


1

Assuming that it is always a monospaced font, sum the image in both axes. img = "your image"; imgdat = ImageData[img]; horiz = Total[imgdat]; vert = Total[imgdat//Transpose]; The resulting lists can be easily searched for peaks and valleys estimating the centers/edges of bounding boxes.



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