13 Replies Latest reply on Apr 12, 2012 10:59 PM by c.pfaffenbichler

# Saving an image as a table of grayscale values?

I have an image that is in grayscale and I need a table that displays each pixels grayscale value.  Is there a way to save the image in some tabular format or can I convert it any other way in photoshop?

• ###### 1. Re: Saving an image as a table of grayscale values?

I have an image that is in grayscale and I need a table that displays each pixels grayscale value

Do you know what you asking? if the image is 12 px x 12 px you can manualy do it... but lets say in a landscape image, grayscale 8 bit, with 256 levels of intensity, and the image is 3000 x 3000 px you will have a table with 9 million rows. Px 1 = 150 px 2 = 151 px 3 = 150... and so on.

G

• ###### 2. Re: Saving an image as a table of grayscale values?

Right, but how can I actually look at the table of the numbers.  I want to put the table of grayscale values into an excel spreadsheet and run an analysis on the values.

• ###### 3. Re: Saving an image as a table of grayscale values?

I want to put the table of grayscale values into an excel spreadsheet and run an analysis on the values.

that said:

Grayscale (8 bit) has 1 channel. (value percentages of black) ie: 1 channel x 8 bits  = 8.  So 2^8 = 256. in other words, There are a maximum of 256 Grayscale

values.

0 = 100% black

256 = White

G

(not sure if something is "lost-in-translation here....)

• ###### 4. Re: Saving an image as a table of grayscale values?

I know how grayscale works.  I have an image in jpeg format.  The image has two different types of rocks, one that is light colored and another that is dark colored and therefore the grayscale value will correspond with the rock type.  I want to take those grayscale values and view them in tabular format so that I can run spatial statistics on the values and quantify the spatial patterns of the different rock types.  I do not know how to go from the jpeg to viewing the grayscale values in a table.  I suppose it's quite easy and perhaps you're confused by my stupidity, but all I want to do is view the actual numbers in a table rather than see the shades of gray.

• ###### 5. Re: Saving an image as a table of grayscale values?

If I understand what you want to do...

With the Grayscale image open, open the info panel (F8 or window>info) select the Eyedroper tool, in the main bar, select sample size, (point, 3x3, up to 101 x 101) hover over the image. The info panel will display the info in %. You can change the panel options to read grayscale. You can also double click on the color picker and with the window open click on the image, the color picker will display info in this case (RGB values should stay the same with each click) and will be the grayscale value.

You can also click and hold the eyedropper tool icon to bring up other related tools: colour sampler being one, but you can only place 4 at a time.

this help?

G

• ###### 6. Re: Saving an image as a table of grayscale values?

You have posed a reasonable question. The short answer is that Photoshop does not have a utility to provide the data you require as you would like it. The closest feature it has which may be of some use is the measurement facility in the Extended version of Photoshop.

Using the measurement facility you can draw a selection around an area of your choosing (one of the rocks, for example) and take the measurement. It will provide you with several pieces of data including Gray value max, min, mean, median, integrated density and histogram. Area & perimeter of the selected area are also included and a few other parameters. All of these data including the numerical data of the histogram can be exported out of Photoshop to be used in a spreadsheet. If these data were useful, you could do a selection around the other rock and do a comparison.

The raw data behind an image can be had from its psd file, but you need to know have some tools to digest that data.

Paulo

• ###### 7. Re: Saving an image as a table of grayscale values?

Using the Extended version of Photoshop you can extract all kinds of image data. You should be able to find something there. Here it shows min, max and average of pixel values (among other things) of a image selection. All can be exported as csv...

• ###### 8. Re: Saving an image as a table of grayscale values?

I forgot to add that you may find the best work environment for your type of task to be the combined use of Photoshop Extended and MATLAB. Communications exist between these programs  using Photoshop JavaScript interface and the MATLAB library interface.

Paulo

• ###### 9. Re: Saving an image as a table of grayscale values?

Paulo and Grant, looks like photoshop doesn't do what I was looking for, but found a freeware gis package to do it instead.  Thanks to both of you for your input.

• ###### 10. Re: Saving an image as a table of grayscale values?

Which one ?

• ###### 11. Re: Saving an image as a table of grayscale values?

Quantum GIS which has a plugin called "QDALtools" that can convert rasters to ascii files (as well as do many other things).

• ###### 12. Re: Saving an image as a table of grayscale values?

Thanks.

I believe you had a typo in your last posting.  GdalTools is the plugin name.

Paulo

• ###### 13. Re: Saving an image as a table of grayscale values?

Maybe Pauls Riggott’s Script (post 5) can help if you are willing to substitute L for K (pasting the grayscale image into the L-channel might be employed).