These are the cases of the Photoshop 911 ER where Adobe Photoshop and Elements users get tips & tricks and answers to their questions about image manipulation, painting. Since 1990 in the Design & Publishing Center, formerly called: Photoshop Tips & Tricks

Using Photoshop to analyze x-rays

The Question:
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!
About the Diagram:
This is a histogram of a 500 X 60 pixel grayscale gradient from level "1" to level "255"

Our reply to a question sent in by: Emma
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.
  1. Mean: the average brightness level for all the pixels in the selection
  2. Std Dv: the average difference between the highest and lowest levels
  3. Median: where the exact "middle" of the selected range occurs
  4. Pixels: how many pixels are actually included in that selection
  5. Level: gives you the numeric "level" of any line you hold the cursor over
  6. Count: gives you the number of pixels in the selection which match the selected level
  7. 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!
From Photoshop 911 Case #04/02/2003
Back to the index

Joseph Kling's complete Photoshop Photo Retouching Seminar
... full 8 Hours of Certified Training in downloadable PDF format!
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

DT&G ezine has been bringing quality design, typography and graphics help to desktop publishers, graphic designers, graphic artists and visual communications practitioners since it's debut on CompuServe and the Mug News Service (MNS) in 1989. The Design & Publishing Center was launched in 1994 and continues to be one of the few remaining web sites to deliver a 90% content to noise ratio -- featuring graphic design, photography, typography, illustration and imformation for designers, graphic artists, creative directors and anyone involved in desktop publishing, design, art, illustration or other visual communications fields.
      Copyright 1993 through 2003, ALL RIGHTS RESERVED. Although DT&G's Photoshop Tips & Tricks department was the first "tips & tricks" publication for Photoshop, it is not officially associated with Adobe Systems, Inc. Photoshop is a Registered Trademark for Adobe Systems, Inc., All Rights Reserved.
      Get your web site reviewed by peers in the web publishing industry, just go to the Web Design & Review wing and visit the Web Site Reviews department where you'll find reader's web sites posted for review. There you'll also find our Web Site Review Submission form for submitting your site for review.
      The Design & Publishing Center is an affiliate of the Graphic Design Network, a wholly owned subsidiary of Showker Inc., trading as Graphic Arts & Design, a Virginia State Corporation since 1972. Affiliates of The Graphic Design Network also include . . . 60-Second Window (tm), the editorial column published online since 1989 with editorials covering computer and online related issues; The Publishers' Warehouse(tm), the freeware, shareware, and tryware department first launched in 1987 publishing a printed catalog of more than 200 disks of clip art, fonts and programs for designers; the News Serve Network(tm), where you can post your own news stories, press releases and information about your products or services -- syndicated across dozens of websites; the User Group Network and the User Group Academy. The Design Center is a proud sponsor of the Association of Apple Computer Users & Groups at
Please come back again!