« New Look! | Main | Emma Peel, You Make Me Wet! »

Notes for Matlab Image Use

Technobabble. You probably want to ignore this.

Matlab doesn't know how to subtract uint8 integers. It probably doesn't know how to do anything with uint8 numbers.

imread() returns a 2d array of uint8s.

dct2() and idct2() both return double 2d arrays, instead of uint8s. They work on uint8s though. Confusing.

I=imread(filename);
imshow(I)
J=dct2(I); -- compute the discrete cosine transform of I
imshow(log(abs(J))); -- display it with logarithm scale
K=J(abs(J) < THRESHOLD) = 0; -- threshold, essentially a compression amount
L=idct2(K)/255; -- inverse dct
imshow(L); -- show the result
M=double(I) - L*255; -- calculate the difference between the images
imshow(M); -- and then show it.

About

This page contains a single entry from the blog posted on July 14, 2004 7:18 PM.

The previous post in this blog was New Look!.

The next post in this blog is Emma Peel, You Make Me Wet!.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.33