How to stretch image horizontally and save it
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Irfan Tahir
le 3 Juil 2017
Commenté : Irfan Tahir
le 3 Juil 2017
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]);
0 commentaires
Réponse acceptée
Image Analyst
le 3 Juil 2017
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);
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Explore and Edit Images with Image Viewer App dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!