필터 지우기
필터 지우기

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);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Explore 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