Counting number of pixel in a specific region of an image

Hi, I have a couple of shark images taken underwater. For the purpose of my project I broke down the shark’s body into different segments and am trying to figure out a way to determine the number of pixels in each of these segments and the number of pixel occupied by the body (essentially the proportion of pixels covered by each area of the body relative to the number of pixels occupied by the total body area of the shark) if possible.

Thanks in advance for your help.

Are you intending to hand draw them or automate the detection of the shark and regions?

Also, you should soon be able to post an image.

In general, though, if you draw an ROI and use the Analyze->Measure function, you should get an area. What that area is measured in will depend on the metadata in the image. Being a camera, it should just be pixels (there shouldn’t be pixel size).

Yes essentially just selecting a segment of the image by hand. I’ve attached an example to the original post. I tried using the ROI but didn’t couldn’t get the number of pixels (unless I was doing it wrong)

Hmm, lets see if this works. May need to refresh the page.

Nevermind, it uploaded as a jpeg for some reason. Not sure if .gif is disabled now :frowning:
Well, that is what you should get if you draw an ROI, and Analyze->Measure. Though the actual measurements vary depending on which ones you set in Set Measurements…

Ok, suddenly working in black and white, with twice the file size. Not sure what is going on.

You may also like QuPath for this sort of project, due to the annotation tools and ability to easily jump around between images in a project, export mass results, and go back and edit anything you later want to change. And being able to CTRL+Z while drawing is a lifesaver.

Thank you so much! I just tried doing it on a couple of images and it worked great! I’ll definitely also give QuPath a try.

If you go the QuPath route, these might give you a decent start on hand-annotating.\

Second one first because it is more fun: 5 - Brush and wand - YouTube

But also some good information on the basics here.

Thank you! It looks like QuPath would be a better option for me since I have a large image database to work with.

1 Like