Finding row and column number of values in an image matrix

15 次查看(过去 30 天)
Hi all,
As the picture attached, on line 39, I am trying to use Find to return row and column numbers of a selected area in the image matrix.
However, it returns Col_r and Row_r with unexpected numbers of values (more than 500k values).
I am not sure whether I use the appropriate function to obtain the row and column numbers of values in the image matrix.
Could you please help provide some suggestion for me. Thank you so much.
  3 个评论
Chutiphon Moranon
Thanks for your reply. I think it is because of the threshold (0.415). When I see the histogram, I find that there is a number of the values after the threshold. I have got another question.
How can I obtain a value (in histogram) of a specific location in my image? Thank you.
Voss
Voss 2022-2-3
To create a histogram of the region of 2D matrix Img12 containing rows start_row to end_row and columns start_column to end_column, you can say:
histogram(Img12(start_row:end_row,start_column:end_column))
i.e., just take the relevant part of Img12 using indexing when calling histogram().

请先登录,再进行评论。

回答(1 个)

KSSV
KSSV 2022-2-3
If your image is a RGB image, the number of column will be product of second and third dimension if you just use size function.
DEmo
I = rand(10,10,3) ;
[m,n] = size(I)
m = 10
n = 30
% You have to use
[m,n,p] = size(I)
m = 10
n = 10
p = 3
Change your line number 28, so that you get Img12L value right.

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by