[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Splitting JPEG files into RGB components



Dana Purton (dpurton@utas.edu.au) writes:

> I am attempting to read a JPEG file into IDL and then split it into the
> three colour
> components so that each component can be analysed separately.  I have
> been
> able to read it in and display it on the screen but am finding it
> difficult to separate it into its red,green,blue components. Is this at
> all possible with JPEG compression, and if so can anyone give me ome
> hints on how to go about it?

Assuming you read the JPEG image into IDL like this:

   READ_JPEG, myfile, image, True=3

You can get the RGB components like this:

   red = image[*,*,0]
   green = image[*,*,1]
   blue = image[*,*,2]

Here is a case where you *want* that single dimension
to disappear. :-)

Cheers,

David

-- 
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155