imbinarize(I) returning "Error using > , Matrix dimensions must agree."
7 ビュー (過去 30 日間)
古いコメントを表示
Hi, I'm having trouble thresholding my grayscale images and my errors don't match any issues I've seen online. I ran into this issue originally with my own grayscale jpegs, but I'm replicating the issue here with the image "George" from this post so that others can run my code if needed.
imbinarize(I) is throwing an error, but imbinarize(I, T) is not:
>> url = 'https://blogs.mathworks.com/images/steve/36/george.jpg';
>> I = imread(url);
>> imshow(I)
>> T = 0.5;
>> bw = imbinarize(I, T);
>> imshow(bw)
>> bw = imbinarize(I);
Error using >
Matrix dimensions must agree.
Error in imbinarize>binarize (line 162)
BW = I > T*classrange(2);
Error in imbinarize (line 152)
BW = binarize(I,T);
Additionally, I tried using graythresh() to determine the threshold, but for some reason it gives me a logical array:
>> T = graythresh(I);
>> whos T
Name Size Bytes Class Attributes
T 256x1 256 logical
Interestingly, multithresh does work:
>> T = multithresh(I)
T =
uint8
112
I recently updated Matlab to ensure that this wasn't a compatibility issue or something, and it's still happening. I'm sure I can use multithresh() to make this if needed, but I'd really like to do this right and to make sure I'm not missing something in my image processing.
Thank you!
1 件のコメント
Voss
2022 年 2 月 18 日
I don't run into the error here:
url = 'https://blogs.mathworks.com/images/steve/36/george.jpg';
I = imread(url);
imshow(I)
T = 0.5;
bw = imbinarize(I, T);
imshow(bw)
bw = imbinarize(I);
imshow(bw)
採用された回答
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


