Image resizing and saving using imwrite

17 ビュー (過去 30 日間)
kunal bhandari
kunal bhandari 2012 年 4 月 27 日
コメント済み: Image Analyst 2014 年 4 月 14 日
hi...i need to resize the images to 512x512 and then save the image....m using imwrite to save but it saving it as blank images...my code is as below...plz help asap..
a=imread('1.jpg');
b=double(a)+1; %converting uint to double
c=imresize(b, [512 512]);
imwrite(c,'1f.jpg');
figure,imshow(a,[]);
figure,imshow(c,[]);
  2 件のコメント
Jan
Jan 2014 年 4 月 14 日
@Horia: setting a flag is though to inform the admins about a question which conflicts with the terms of conditions. So please remove this flag and post a new question instead. Thanks.
Image Analyst
Image Analyst 2014 年 4 月 14 日
I moved it.

サインインしてコメントする。

採用された回答

Jan
Jan 2012 年 4 月 27 日
If you work with images in DOUBLE format, limit the values to the interval [0, 1]. Therefore prefer IM2DOUBLE instead of double(a)+1.
  4 件のコメント
Jan
Jan 2014 年 4 月 13 日
@Horia: I do not agree. Converting to logical can work for black&white images only. For color images working in the DOUBLE format is sufficient, when you call imwrite with the correct inputs. If you have troubles, please post the corresponding code and the used type of the inputs.
Image Analyst
Image Analyst 2014 年 4 月 14 日
Horia's "Flag" moved here:
I had to use: Convert grayscale to binary MyBinary = (MyGray > 0.5); when trying to resize a transparent .gif image. Otherwise (with double(imread(('image.gif'))), I had a correct image with imshow, but imwrite('...','TransparentColor',1) saved a totally black transparent image.

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2012 年 4 月 27 日
Don't convert to double. jpg images expect uint8 values.
  3 件のコメント
kunal bhandari
kunal bhandari 2012 年 4 月 27 日
converting to double is necessary for my further prgms...i have tried saving in other formats also but with the same result...
Image Analyst
Image Analyst 2012 年 4 月 27 日
If you want to save double images and will use them only in MATLAB, then I recommend saving them as a .mat file. If you want a visualization so that you can see them in other programs, like a jpg file, then use 255 * mat2gray() to scale to 0-255 before saving in a standard format like BMP, TIF, PNG, JPG, etc.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by