Ask Your Question
0

how to process tiff image

asked 2013-03-12 08:10:42 -0600

lyw8120 gravatar image

Yes, opencv can easily to read iamge, but how to process it because its compress, and its data type.

I want to do a dft after import tiff image. but failed. showed that it should be CV_32FC1, CV_32FC2 etc.

That means opencv did not convert the data type to its own data type, right?

so how to solve this problem

thanks.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
3

answered 2013-03-12 09:23:43 -0600

berak gravatar image

updated 2013-03-12 16:04:58 -0600

this will require a grayscale(1 channel) image, so we convert it to grayscale when loading:

Mat img = imread("my.tiff", CV_LOAD_IMAGE_GRAYSCALE);

since this is still uchar data (CV_8UC1) you 'll have to convert it to floating type:

Mat ff_in;
img.convertTo( ff_in, CV_32FC1, 1.0/255.0 );  // [0..1] range

run the dft:

Mat ff_out;
dft( ff_in, ff_out );

then, convert it back:

Mat ff_gray;
ff_out.convertTo( ff_gray, CV_8UC1, 255.0 );
imshow("lalala",ff_gray);
edit flag offensive delete link more

Comments

Thanks a lot, that is what I need. the first big problem is to convert data type from one library to another one for a new man.

lyw8120 gravatar imagelyw8120 ( 2013-03-12 17:32:39 -0600 )edit
1

answered 2013-03-12 08:14:30 -0600

It is quite easy, just use the C++ functionalit which will do the type conversion for you.

Mat img = imread(location);
edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-03-12 08:10:42 -0600

Seen: 10,899 times

Last updated: Apr 26 '13