2
$\begingroup$

enter image description here

I have this image I want to separate green circles from yellow circle in two different images whiteout changing the pixel intensity information. I used the mean intensity

For[jj = 1, jj < pix + 1, jj++, If[image[[ii, jj]] > 85, image[[ii, jj]] = 0.00001, 
image[[ii, jj]] = image[[ii, jj]]]]];

ListDensityPlot[image, ColorFunction -> GrayLevel, PlotRange -> All] I tried to make the yellow circle intensity zero (which is around 85) how can I delete the circles based on their intensity values?

$\endgroup$
0
$\begingroup$

To delete pieces of an image depending on the intensity you need the raw data of the image. This can be done by "ImageData", assuming your image ist stored in "image":

id= ImageData[image];

Next we need to know how many channels your data has:

ImageChannels[image]
(* 4 *)

We have four channels. Inspection of the data in, my case (your case may be different because your image is stored differently), reveals that the forth channel is always 1 and I guess channel 1..3 are red, green blue or some other color encoding. Therefore I take the sum of channel 1..3 as measure for the intensity. With this we may zero pixels according to intensity. E.g. to get light pixels:

dat = Map[If[Total[#[[1 ;; 3]]] > 0.6, #, 0 #] &, id, {2}];
Image[dat]

enter image description here

For the fainter blobs this will not work as there are faint pixels around the light blob. More evolved methods are needed for this, e.g. masking and ImageApply.

$\endgroup$
3
  • $\begingroup$ That's an interesting answer, but I'm wondering, why the black background color is kept. Any idea? Thanks! $\endgroup$ Oct 26 at 13:43
  • $\begingroup$ @Ulrich Neumann Hi Urlich, I zero out pixels with low intensity. Therefore, a black background stays black. $\endgroup$ Oct 26 at 14:22
  • $\begingroup$ I got it , thank you! $\endgroup$ Oct 26 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.