Using Photoshop to analyze x-rays
Our reply to a question sent in by: Emma
Counting pixels in selections:
Is there any way that the area within a selection can be measured? We need to compare the size of different density areas on x-rays. Ideally we are hoping to be able to select the two different areas using the magic wand tool, get an idea of the number of pixels in each area,and then produce a percentage as a result. We would be very grateful for any hints you can offer us. Thank you!
- What a fantastic question! I love it!
This question got me so curious I spent the next three hours figuring stuff out. I know what you're asking, but I don't know why. I can only speculate. The Histogram dialog gives you everything you want to know, and then some.
First, you should convert the x-ray to grayscale. (I assume x-rays are grayscale, correct me if I'm wrong.) This rules out color variations from skewing the results.
In working to answer your question I discovered there really are some ways to have Photoshop help in analyzing such images.
Let's say a particular "color" or density value in an x-ray means a particular condition.
First figure out what particular pixel you plan to sample, and what range of similar pixels is appropriate to include in the sampling. Set the Wand tool appropriately.
You click on a particular gray area with the wand, then pull up the Image > Histogram dialog to get the statistics.
(Open Histogram diagram now.)
Move your mouse very slowly over the lines and you'll see that each vertical row of pixels represents a single level in the selected group of pixels. Theoretically you could assign specific "ailment" to a certain level or groups of levels.
- Mean: the average brightness level for all the pixels in the selection
- Std Dv: the average difference between the highest and lowest levels
- Median: where the exact "middle" of the selected range occurs
- Pixels: how many pixels are actually included in that selection
- Level: gives you the numeric "level" of any line you hold the cursor over
- Count: gives you the number of pixels in the selection which match the selected level
- Percentile: how many pixels possess a value darker than the selected one
- From that information you could (again, theoretically) build some fairly sophisticated analysis criteria for reading x-rays. But there's so much more information there as well.
- Take that to a new level
(No pun intended!) Suppose you've designated which specific levels or ranges of levels represent an ailment or condition or feature in in the patient's x-ray -- for instance bone mass.
Now you can use the Select > By Color command and select those levels (colors) which stand for the specific data searched for and the Histogram will give you the statistics of the selection. You could fine-tune that to a single value if you wanted to, then run the Histogram for the whole file.
Once you start playing around with the feature, and doing 'what-if' scenarios it becomes quite interesting. Although I'm sure there's already specialized medical equipment which does the above much faster and much more accurately, this is a pretty neat feature of Photoshop that few people even bother to look at.
Please let us know if you found this helpful!
- Back to the index
- Photoshop, and Elements emergencies:
- call the Emergency Hot Line and list your symptoms, version and OS. Help will be on the way.
- Photoshop Practitioners:
- Submit your Photoshop tutorial or training site to the Photoshop 911 emergency directory so we can refer users to your site. Practitioners can also contact us to become a Photoshop911 partner.
- Got a tutorial?
- If we publish your tutorial, how-to article, tip or trick, you'll be rewarded with selections from the Designers' Bookshelf!
- Thank you for visiting
- . . . the Photoshop Tips & Tricks department of the Design & Publishing Center Don't forget: this is a reader-driven web site. We need your input and participation to continue bringing great content to Photoshop users everywhere at no charge.
High content, low noise since 1990