Ana Ain
Ana Ain

Reputation: 173

how to get feature of png image using 2d dct?

Could I use dct to extract the feature of .png images? Or dct is just for jgp? Because my dataset using png format.

I've read several journals, and find that 2d dct could used to extract the feature based on coefficient. I need the features for Neural Neutwork. I've tried basic code to do 2d dct (using matlab):

i = imread ('AB1.png');
b = im2double (x);
d = dct2 (b, [64 64]); 

but, i am still not sure, that this code really give me the appropriate feature that i need. do you have any recommendation of another codes?

And also why 'dctmtx' function give me the same coefficient for different image? *Thanks before.

Upvotes: 3

Views: 1809

Answers (1)

GameOfThrows
GameOfThrows

Reputation: 4510

First, png does not matter, as long as you are not doing some alpha channel processing etc, reading png is just like reading jpg since you are doing your DCT on the matrix representation of the image - instead of the file.

Your code:

d = dct2 (b, [64 64]); 

should give you the 2d-DCT of the zero padded 64 by 64 image.

To check you could try something like:

d = dct(dct(b.').') %//If you want to pad your image with zero first.

since dct2 is implemented using dct at core.

as for dctmtx - it should give you the dct matrix which you can apply to your image matrix to obtain the dct result of your image (Thus , the result generated by dctmtx should be the same for any image that are the same size). Matlab gives a clear example:

A = im2double(imread('rice.png')); %//your image
D = dctmtx(size(A,1));  %//Generate a DCT matrix of the SIZE of your image
dct = D*A*D';  %//Obtain 2D - DCT 
figure, imshow(dct)  %//Result transform

All three examples should give you the same result.

And finally, in terms of best feature extraction algorithm/transformation, it really depends on what you are trying to achieve - recognition/enhancement/encryption but in general, DCT is very good and efficient for regular images.

Upvotes: 1

Related Questions