how to solve too many arguments error?

7 ビュー (過去 30 日間)
hardeep thethi
hardeep thethi 2016 年 10 月 8 日
コメント済み: Guillaume 2016 年 10 月 8 日
when i try to display multiple images using the formula below. i get error of too many arguments. when i execute the first statement , it gives me error. what am i doing wrong? the code is as follows:
if true
% code
[X1,map1]= image; ///image variable contains original jpg image.
[X2,map2]= image2; /// image2 variable contains transformed image.
subplot(1,2,1), imshow(X1,map1)
subplot(1,2,2), imshow(X2,map2)
end

採用された回答

Guillaume
Guillaume 2016 年 10 月 8 日
Note: it is recommended that you do not use image as a variable name since it's already the name of a function in matlab.
The syntax [X, map] = is normally used in conjuction with imread to load an indexed image (rgb or grayscale images don't have an associated colour map), as in:
[X, map] = imread('someindexedimage.bmp');
Now, since the jpg format does not support indexed images, you'd never use that syntax for a jpg image.
Furthermore, the syntax
[something, something] = someothervariable;
would never be valid, since you're trying to assign a single variable into two variables.
In the end, if image and image2 are truly jpg images, then to display them simply:
subplot(1, 2, 1), imshow(image); %would be better called image1
subplot(1, 2, 2), imshow(image2);
Or you could do:
imshowpair(image, image2, 'montage');
  2 件のコメント
hardeep thethi
hardeep thethi 2016 年 10 月 8 日
your first option worked for me. the imshowpair brings an error- Undefined function or method 'imshowpair' for input arguments of type 'uint8'. what if i want the two images to appear in one axis since one is transformation of other is it possible and how?
Guillaume
Guillaume 2016 年 10 月 8 日
You need the imaging toolbox for imshowpair.
As far as I know, you can only have one image per axis. If both images are the same height, you can always do:
imshow([image1, image2])
to have them side by side.

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

その他の回答 (1 件)

Kishore Kumar
Kishore Kumar 2016 年 10 月 8 日
if true
% code
X1 = image;
X2 = image2;
subplot(1,2,1), imshow(X1,map1)
subplot(1,2,2), imshow(X2,map2)
end
  1 件のコメント
hardeep thethi
hardeep thethi 2016 年 10 月 8 日
hi thanks for taking time to answer, but the code is giving me error of -undefined function or variable 'map1'.

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

カテゴリ

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