How to fix ROI size irrespective of image

1 回表示 (過去 30 日間)
Kirti
Kirti 2013 年 3 月 19 日
I have multiple images and I am using imcrop function to take ROI in image. The problem with imcrop is it gives me different size of ROI on each image. I would like to take ROI of same size for each image. There is a option in imcrop by which I can select size but for that I need to keep my location of ROI fix. I want to fix window size but vary location of window on image. Is there a function available for this functionality in Matlab?

回答 (1 件)

Image Analyst
Image Analyst 2013 年 3 月 19 日
If you don't need to interactively size it, then just hard code the values and use normal, regular indexing:
row1 = 100; % or whatever.
col1 = 200; % or whatever.
row2 = 150; % or whatever.
col2 = 225; % or whatever.
croppedImage = grayImage(row1:row2, col1:col2);
  4 件のコメント
Kirti
Kirti 2013 年 3 月 20 日
Thanks. I am trying to understand how ginput will give me fix size ROI? I am getting coordinates by ginput. And ROI coordinates will vary image to image. Can you please let me know if I have to use any other parameters of ginput to get fix ROI?
Image Analyst
Image Analyst 2013 年 3 月 20 日
You know the size, so you simply add it to the coordinates.
[col1, row1] = ginput(1);
row2 = row1 + height; % You know the height because you fixed it.
col2 = col1 + width; % You know the width because you fixed it.

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

Community Treasure Hunt

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

Start Hunting!

Translated by