Skip to main content

Inverse DCT

2 replies [Last post]
shit_happens
Offline
Joined: 2010-06-14

Hello,

I have a "very simple" beginners problem. I searched the forum and the archive for hours, still I just couldn't find the solution. I want to simply transfer a greyscale image with DCT to the frequency domain and back using JAI. I have some mistake in my code I guess cause I just get a strange almost white picture back after the IDCT. Here is a code snipped, maybe somebody can help me?

BufferedImage b = cover;
ParameterBlock pb = (new ParameterBlock()).addSource(b);
PlanarImage dct = JAI.create("dct",pb,null);
ParameterBlock pb2 = (new ParameterBlock()).addSource(dct);
PlanarImage idct = JAI.create("idct", pb2, null);

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
shit_happens
Offline
Joined: 2010-06-14

A small addition:
I checked the pixel values manually and also the Color Model they seem to be identical (after and before the dct and idct transformations) so the transformations seem to be done correctly. But outputting the image with

ImageIO.write(img,"png",new File("my_file.png"))

creates an image different from the original one. It is a TYPE_USHORT_GRAY im.

Fork Labs

Hello shit_happens,

If you did any filtering in the frequency domain, you need to
recalibrate your image once you are back into the spatial domain, that
is rescale you pixel values between 0 and 255.

Also, you might want to use this pipeline :

original -> to float (or double) -> DCT -> filter -> IDCT ->
rescale -> to ushort

You can check my project https://jai-operators.dev.java.net/, it
contains some operators that might be of help.

Regards,

Daniel Léonard

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net