White pixel count within ROI, and outside ROI. To compare later

particle-counting
roi
fiji
Tags: #<Tag:0x00007fd542235220> #<Tag:0x00007fd5422350b8> #<Tag:0x00007fd542234f78>

#1

Hello dear friends,

I am trying to count the green pixels within the red lines (blood vessels). And later the green pixels outside te red lines (inside the alveoles). So I can compare them.

Suplementary information of what I tried.
(I am not really sure if it’s the right direction)

Image>color>make composite
Image>color>split Channel
(for red image) Image>adjust>treshold ; default ; B&W

(green image) Image>adjust>treshold

Edit>selection> create mask
Proces>binary>fill holes
(to fill blood vessels?)

Edit create selection
Image>overlay>Add selection (ctrl+B)
Image>Overlay>To ROI manager
Image>Overlay>From ROI manager
(now the selection from the red lining is on the green dots picture, but sometimes it also excludes the green dots inside the red lines. So it is not fully correct)

Set measurement>limit to treshold
I tried measure in ROI but it doesn’t give me any real information.

Thank you for your suggestions
Best regards,
John


Background Particles
#2

Good day John (who loves bold type faces)!

Red and green channel images both show clear regions with values > 0. Therefore, you can threshold them accordingly which gives you two binary images.

To get the “green on red”-signal you may multiply the binary images which gives you the product image that is again a binary image.

To get the “green outside red”-signal you may take the difference of the binary product image and the green binary image.

HTH

Herbie


#3

Thank you very much for your answer Herbie. :slight_smile:

So I tried you suggestion.
First I set treshold for R and G image.
Then:
Process>Image calculator
Multiplication

And for the subtraction

Now to count the black pixels from the multiplication it would give met the green from inside the red lines, if I understand it correctly.

How would I measure the black pixels from the multiplication. Because the measurement tool only counts white? And it looks like ImageJ won’t invert the calculated images. Last question: the number under area from the measurement tool this is the count of black pixels?

Thank you again very much for your help.
Kind Regards, John


#4

Well John,

you may try the following ImageJ-macro that you can paste to an empty macro window (Plugins >> New >> Macro) and run it after you’ve opened your color image.

setBatchMode( true );
run("Make Composite");
setSlice( 3 );
run( "Delete Slice", "delete=channel" );
setSlice( 1 );
changeValues( 1, 255, 1 );
setSlice( 2 );
changeValues( 1, 255, 1 );
run("Stack to Images");
imageCalculator( "multiply create", "Red", "Green" );
selectImage( "Result of Red" );
rename( "GreenOnRed" );
getRawStatistics( N, mn );
print( "GreenOnRed = " + N * mn + "pel" );
run("8-bit");
setMinAndMax( 0, 1 );
selectImage( "Red" );
close();
imageCalculator( "difference create", "GreenOnRed", "Green" );
selectImage( "Result of GreenOnRed" );
rename( "GreenOutsideRed" );
getRawStatistics( N, mn );
print( "GreenOutsideRed = " + N * mn + "pel" );
run("8-bit");
setMinAndMax( 0, 1 );
selectImage( "Green" );
close();
setBatchMode( "exit and display" );

HTH

Herbie


#5

Thank you very much Herbie!
That’s more as perfect!
My best wishes to you,
have a great day!