M�rten Blixt writes:
> Searched through the group listings, and elsewhere, but didn't find
> any useful
> information. So I try posting.
>
> I have a serie of color images (3 x X_Size x Y_Size) in png format,
> which I wish to
> modify slightly and then write back as indexed png images, and I'm
> working on a
> MAC OS X with IDL 5.6.
> But the result look very bad, as if I only have like 12 color levels!?
>
> My pseudo code goes something like
>
> SET_PLOT, 'Z', /COPY ;write to the Z 'pseudo' buffer - no output to
> terminal
> DEVICE,SET_RESOLUTION=[XSize,YSize], Z_Buffer=0
>
> FOR i = 0,N-1 DO BEGIN
> image = READ_PNG(FileName[i])
> TVIMAGE, image
> ;Some "non-invasive" image modification, like adding text with
> XYOUTS
>
> a = TVREAD()
> TVLCT, r, g, b, /GET
> image24[0,*,*] = r[a]
> image24[2,*,*] = g[a]
> image24[2,*,*] = b[a]
>
> WRITE_PNG, ResultFileName[i], image24
> ENDFOR
>
> N is around 1000, so I thought that I would save time using the
> Z-buffer. I've used a
> similar code, but then writing to the X device and saving the image
> using TVRD(True),
> which works fine. What wrong do you think I do in the Z-buffer??
Well, there are a couple of things wrong here. First of all,
even though you say you want to write these back as "indexed"
PNGs, you are actually writing them back as 24-bit images!
So, assuming you *don't* want indexed PNGs, and assuming you
*don't* want to see the image going into a window on the display,
I would write the code like this:
Window, /Free, /Pixmap, XSize=xsize, YSize=ysize
FOR j=0,N-1 DO BEGIN
image = Read_PNG(filename[j])
TVImage, image
XYOuts, .....
infile = StrSplit(filename[j], '.', /Extract)
outfile = infile[0] + '.processed'
ok = TVRead(Filename=outfile, /NoDialog, /PNG)
ENDFOR
WDelete, !D.Window
If the file goes in with the name "image_1.png", it comes out with
the name "image_1.processed.png".
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|