I don't understand this ROI code. can someone explain it?
1 回表示 (過去 30 日間)
古いコメントを表示
I have this image. How can I know the start row and column as well as off set of this picture? I don't understand the code below.
This is the example code that I've got from tutorial. Can someone please explain to me ?
% you can obtain the coordinates of the rectangular region using
% pixel information displayed by imtool
start_row = 34;
start_col = 208;
cropRGB = RGB(start_row:163, start_col:400, :);
imshow(cropRGB)
% Store (X,Y) offsets for later use; subtract 1 so that each offset will
% correspond to the last pixel before the region of interest
offsetX = start_col-1;
offsetY = start_row-1;
0 件のコメント
回答 (1 件)
Florian Morsch
2018 年 5 月 11 日
編集済み: Florian Morsch
2018 年 5 月 11 日
Well, this code simply creates a ROI starting at point X 34 and Y 208, with the endpoint at 163 and 400.
You should make your question more clear, how can you know the start row and column? Well, its there in the code, 34 and 208. In the comment its seen you can get the information with imtool, so my guess is someone opened the image, defined a ROI and this ROI starts at 34,208. Could also have started at 30,200... Without more information you cant tell.
I asume you also have some kind of description to the tutorial, so i might guess there is a info on the ROI you want to find. Something like: "Cut out the bike rider" or something like that. So you specify a area you want to crop, which in this example starts at X34 Y208.
The offset is just the starting point of your ROI - 1, its defined by whoever wrote that code, it also could be "offsetX = start_col-20". There are not enough information given why the offset and X/Y are defined like that.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!