フィルターのクリア

How to stretch image horizontally and save it

9 ビュー (過去 30 日間)
Irfan Tahir
Irfan Tahir 2017 年 7 月 3 日
コメント済み: Irfan Tahir 2017 年 7 月 3 日
Hi, how to stretch an image horizontally and to save the image. I did found the code on the website but i couldnot able to do it. I am having difficulty using the code
% code Img=imread('b1.tiff');
[rows columns numberOfColorChannels] = size(Img);
subplot(2, 1, 1);
imshow(Img);
newWidth = [1 0.592013 * columns];
subplot(2, 1, 2);
imshow(Img, 'XData', newWidth);
stretchedImage = imresize(Img, [rows newWidth]);
But i couldnot able to save the image. It gives an error of
Error using coder.internal.errorIf (line 8)
Function IMRESIZE expected input number 2, MAP, to be a valid colormap. Valid colormaps cannot have values outside the range [0,1].
Error in iptcheckmap (line 47) coder.internal.errorIf(true, 'images:validate:badMapValues', ...
Error in imresize>parsePreMethodArgs (line 343) iptcheckmap(map, mfilename, 'MAP', 2);
Error in imresize>parseInputs (line 248) [params.A, params.map, params.scale, params.output_size] = ...
Error in imresize (line 141) params = parseInputs(varargin{:});
Error in rescale (line 8) stretchedImage = imresize(Img, [rows newWidth]);

採用された回答

Image Analyst
Image Analyst 2017 年 7 月 3 日
newWidth needs to be a single integer, not a 1-by-2 array of floating point numbers. This works:
Img=imread('cameraman.tif');
[rows, columns, numberOfColorChannels] = size(Img);
subplot(2, 1, 1);
imshow(Img);
newWidth = round(0.592013 * columns)
subplot(2, 1, 2);
stretchedImage = imresize(Img, [rows newWidth]);
imshow(stretchedImage);
  1 件のコメント
Irfan Tahir
Irfan Tahir 2017 年 7 月 3 日
thanks alot.....cheers

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeExplore and Edit Images with Image Viewer App についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by