• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Pixel count using histogram incorrect even after uncached refresh

New Here ,
Feb 17, 2020 Feb 17, 2020

Copy link to clipboard

Copied

Hello,

 

I'm hoping to get some help to resolve this issue. I'm using photoshop to calculate the area of some histological slides. The different areas I'm calculating are 1) Total area, 2) Area at risk 3) Necrotic (dead) tissue.  Obviously the total area should be the largest, the area at risk the second largest and the dead tissue the smallest. I only need values as percentage of each other so converting to millimeter or some other unit is unecessary - I just want area at risk as a % of total area and and dead tissue as a % of area at risk. Should be simple, right?

 

I'm doing this by tracing each of the areas in separate layers and coloring them with a single color. Then I select only one layer and open the histogram, do uncached refresh to the get the pixel count. However, I'm getting the same pixel count on every layer even though they are obviously different sizes. If I use the magic wand to do a pixel count with similar colors the data I get back are equally nonsense, with larger areas getting lower pixel counts than smaller ones.

 

Does anyone know how to fix this problem? Thanks in advance!

Views

1.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 17, 2020 Feb 17, 2020

I just tried and got some strange results here.

 

Try this though

Select the layer to be measured in the layers panel and switch off visibility of all other layers. Use Ctrl+D to clear any existing selection and then use the object selection tool to select the pixels - just draw around the entire image and the tool will select all the pixels on the layer. The histogram should now show an accurate uncached count of that layers pixels.

It seems to work here - even with just a handful of individual

...

Votes

Translate

Translate
Adobe
Community Expert ,
Feb 17, 2020 Feb 17, 2020

Copy link to clipboard

Copied

Please provide a sample file. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 17, 2020 Feb 17, 2020

Copy link to clipboard

Copied

»Then I select only one layer and open the histogram, do uncached refresh to the get the pixel count.«

Do you mean you select the Layer in the Layers Panel or that you laod the Layer’s transparency as a Selection (by cmd-clicking it in the Layers Panel)? 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 17, 2020 Feb 17, 2020

Copy link to clipboard

Copied

I select the layer of interest in the Layer-menu on the right and deselect all other layers so only one layer shows up. I'm not sure what you mean with loading the layer's transparency as selection by cmd-clicking in the layer panel (is that a Mac-thing? I'm using PC).

 

Here's a screengrab of what it looks like. Underneath you see an untraced cross section.  The green is is the whole area (blue, red and white stain), the yellow is the area at risk (red and white stain) and the red is the necrotic area (white stain). Each are is its own separate layer as you can see on the right. 

PhotoshopIssue.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 17, 2020 Feb 17, 2020

Copy link to clipboard

Copied

If you need the Histogram numbers in another application you should probably use a Script to save them all at once as a txt or copy them to the clipboard etc. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 17, 2020 Feb 17, 2020

Copy link to clipboard

Copied

Change the histogram source to Selected layer

 

2020-02-17_10-35-33.jpg

Dave

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 17, 2020 Feb 17, 2020

Copy link to clipboard

Copied

Thanks for your reply. I have already done that.  I'm still getting unreliable data, with different pixel counts each time.

 

These are all from the same cross section:

 

Total SizeAARNecroAAR/TotInf/AAR
68025284561885141,83 %66,25 %
2716371125167348041,42 %65,31 %
45022003151044,49 %75,54 %

 

How can I know which one is accurate?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 17, 2020 Feb 17, 2020

Copy link to clipboard

Copied

I just tried and got some strange results here.

 

Try this though

Select the layer to be measured in the layers panel and switch off visibility of all other layers. Use Ctrl+D to clear any existing selection and then use the object selection tool to select the pixels - just draw around the entire image and the tool will select all the pixels on the layer. The histogram should now show an accurate uncached count of that layers pixels.

It seems to work here - even with just a handful of individual pixels marked

 

Dave

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 17, 2020 Feb 17, 2020

Copy link to clipboard

Copied

This seemed to do the trick! When I use the entire background image the pixel count matches the pixel dimensions of the whole image, so this should be the correct count.  Thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 17, 2020 Feb 17, 2020

Copy link to clipboard

Copied

Yea, histgram work on an entire image, unless a selection is made. They it will just do the selection. It will also count transparent pixels as white - not really your issue at this time, but something to be aware of.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 09, 2021 Mar 09, 2021

Copy link to clipboard

Copied

Chuck I have a quick question about the above.

I'm doing a similar thing as the author above. I want to get a pixel count for the amount of blue within a selection on photoshop. 

I simply highlight the area using the selection tool, and use histogram to get the total pixel count in the selection, and the blue part of the histogram to get a pixel count for the blue. 

When I do this I get 2-3 peaks. I think this is because of light blue and dark blue within the image. 

If I simply count up these 2-3 peaks, will this give me the total blue count? Or are these peaks a mix of blue and another colour... Thanks for your help

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 09, 2021 Mar 09, 2021

Copy link to clipboard

Copied

If you're selection just has blue in it, then, yes, you will get different peaks depending on the brightness and hue of the blue.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 09, 2021 Mar 09, 2021

Copy link to clipboard

Copied

Yes that's true, but the selection has red yellow green and blue in it. But I'm only interested in the blue. When I select the image, the histogram under blue gives a couple of peaks around 120 and 250. There are also much smaller peaks dotted around 80, 100 etc. 

 

There are two main shades of blue, dark and light. I think that's the cause for the two peaks. If I simply add together the pixel count for these will I get a total count for the blue? Or are some of these peaks under the blue, contribute by the the green within the image? 
sorry if this is very basic, I'm new to histogram and photoshop generally. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 09, 2021 Mar 09, 2021

Copy link to clipboard

Copied

Just about any color could have blue in it, so unless the selection just has visual blue in it, the values will be skewed. You might be better trying to make a selection using L*A*B, where you can isolate blue easier. Or making a selection, then using color range to further isolate the desired blues in that selection.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 10, 2021 Mar 10, 2021

Copy link to clipboard

Copied

Thabks Chuck, how do I used the LAB Function? Is that just the colour sampler? 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 10, 2021 Mar 10, 2021

Copy link to clipboard

Copied

LATEST

You would use L*A*B* to make selections using channels. The B channel is the blue channel, with the darker areas having blue in them. Using color range in RGB might work better and be easier.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines