# How to separate these circle based on their pixels mean intensity?

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?

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]


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.

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