Error using ./ Matrix Dimensions Must Agree ??!! how to solve this??

im getting error in the 4th line for ./ wat should i change ?
l=getimage(handles.axes1);
s=getimage(handles.axes3);
imsave(handles.axes3);
r=double(s)./(double(l)+1.0);
imshow(r,'Parent',handles.axes5);
i used images of same dimensions too

13 件のコメント

Stephen23
Stephen23 2017 年 1 月 18 日
"wat should i change"
The size of s and/or l.
Divya Praisy
Divya Praisy 2017 年 1 月 18 日
the size of an image loaded will it be the dimension if so then it is for example : 278 X 370pixels both images
Stephen23
Stephen23 2017 年 1 月 18 日
@Divya Praisy: please put these two commands on the line before the one with the error:
size(l)
size(s)
and then tell us exactly what they print in the command window.
Divya Praisy
Divya Praisy 2017 年 1 月 18 日
370 278
370 278 3
Divya Praisy
Divya Praisy 2017 年 1 月 18 日
Stephen23
Stephen23 2017 年 1 月 18 日
編集済み: Stephen23 2017 年 1 月 18 日
"i used images of same dimensions too"
No you didn't. Array l has a different size to array s. The fact that these arrays represent images with the same number of pixels is irrelevant: these are two arrays with different sizes.
Divya Praisy
Divya Praisy 2017 年 1 月 18 日
i have given the size of images is not the same still
Guillaume
Guillaume 2017 年 1 月 18 日
編集済み: Guillaume 2017 年 1 月 18 日
It must be noted that if Divya was using the latest version of matlab the error would not have occured due to the implicit expansion for compatible array sizes introduced in R2016b.
It's always worth mentioning in your question if you're not using the latest version.
Divya Praisy
Divya Praisy 2017 年 1 月 18 日
i am using R2016b
Guillaume
Guillaume 2017 年 1 月 18 日
Either you're not using R2016b, or the dimensions are not as you've stated:
s = rand(370, 278); %a 370 x 278 matrix
l = rand(370, 278, 3); %a 370 x 278 x 3 matrix
r = double(s) ./ (double(l) + 1)
produces no error in R2016b. r has size 370 x 278 x 3
Divya Praisy
Divya Praisy 2017 年 1 月 18 日
then is it not working did i write anything wrong??
Divya Praisy
Divya Praisy 2017 年 1 月 18 日
Sorry i am using R2016a
is it not available in it
Guillaume
Guillaume 2017 年 1 月 18 日
I answered your question over an hour ago with a solution that works in any version of matlab. See down there
||
||
\/

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

 採用された回答

Guillaume
Guillaume 2017 年 1 月 18 日
編集済み: Guillaume 2017 年 1 月 18 日

0 投票

Clearly, one of the image is a grayscale image and the other is RGB.
And clearly, you're not using R2016b since your division would have succeeded in that version due to the introduction of implicit expansion. In older versions, to achieve the same result:
r = bsxfun(@rdivide, double(s), double(l)+1);
That is assuming, of course, that you want to compute the ratio of each RGB channel with the grayscale image.

その他の回答 (0 件)

カテゴリ

質問済み:

2017 年 1 月 18 日

コメント済み:

2017 年 1 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by