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 个评论
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
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)
% You have to use
[m,n,p] = size(I)
Change your line number 28, so that you get Img12L value right.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!