Using imwrite after DWT and IDWT

조회 수: 4 (최근 30일)
vikas
vikas 2012년 3월 21일
I am having a problem while using imwrite after performing DWT and IDWT operations on an gray image.
the problem is that after the imwrite operation when i click on the resulting image file all that i am able to view is a white background instead of an image.
Is there any method to overcome this problem.
for example: if x is an m*n gray scale image then what i have done is
[A,B,C,D]=dwt2(x,'haar');
.....
.....
.....
here i have done some manipulations on the sub-bands(B,C,D)
.....
.....
.....
y=idwt2(A,B,C,D,'haar');
imwrite(y,'C:\Users\HOME\Desktop\IMAGEPROCESS','jpg');
After all these operations when i use imshow(y,[]) the correct image is being displayed. But its not the same case when i try to open the JPG image file(named IMAGEPROCESS in the Eg) as a result of the imwrite operation.
KINDLY HELP

채택된 답변

Wayne King
Wayne King 2012년 3월 23일
Hi Vikas, Interesting application.
Your problem is just scaling before you write the .jpg file. Without scaling, virtually all the elements of your image matrix are written to the value 255 in the .jpg file, which is why it appears all white when you display.
Execute these lines:
x = idwt2(CA,CH,CV,CD,'haar');
x = x/255;
imwrite(x,'C:\Users\HOME\Desktop\imageprocess.jpg','jpg');
Im = imread('C:\Users\HOME\Desktop\imageprocess.jpg');
imshow(Im,[]);
Hope that helps
  댓글 수: 1
vikas
vikas 2012년 3월 23일
Hey Wayne Thank You very much

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Wayne King
Wayne King 2012년 3월 21일
imwrite() converts images to RGB before writing a jpeg file.
Can you please try writing a .png file and see if you have the same problem?
  댓글 수: 4
vikas
vikas 2012년 3월 22일
Yes i am using MATLAB
Wayne King
Wayne King 2012년 3월 22일
Hi Vikas, can you go over to CSSM and there you will see my email. Send me the original image along with the MATLAB code you use to manipulate the coefficients and I will have a look. It's hard to go further without more information.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by