フィルターのクリア

How to edit ROI after already saved?

9 ビュー (過去 30 日間)
Jonah
Jonah 2023 年 5 月 25 日
コメント済み: Jonah 2023 年 5 月 31 日
I have a set of images, with ROIs already drawn on them using drawpolyline. I would like to now be able to open the images with the ROIs, and modiy them (ie. make them bigger/smaller, move them around). Is there any way to do this?
  1 件のコメント
DGM
DGM 2023 年 5 月 25 日
編集済み: DGM 2023 年 5 月 25 日
How exactly did you "save" an ROI object on an image? Do you mean that you drew a white polygon on an image? If so, you might be able to get an approximation of the original polygon from the modified image, but you won't get the original image information back, so modifying the polygon in the edited image itself is not generally possible (unless you have the original image).
You'd have to provide an example of what you've done in order to know.

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

採用された回答

Shubham
Shubham 2023 年 5 月 31 日
Hi Jonah,
Yes, you can open images with ROIs and modify them in MATLAB using the imshow function and the imrect, imellipse, or imfreehand functions for selecting ROIs.
Here's some sample code to get you started:
% Load image
img = imread('path/to/image.jpg');
% Display image
imshow(img);
% Define ROI
roi = imrect;
% Alternatively, you can use imellipse or imfreehand to create different kinds of ROIs.
% Get ROI position
pos = getPosition(roi);
% Modify ROI position
pos(3) = pos(3) + 50; % Increase width of ROI by 50 pixels
pos(4) = pos(4) + 50; % Increase height of ROI by 50 pixels
pos(1) = pos(1) - 25; % Move ROI 25 pixels to the left
pos(2) = pos(2) - 25; % Move ROI 25 pixels up
% Update ROI
setPosition(roi, pos);
% Get image inside ROI
cropped_img = imcrop(img, pos);
% Display cropped image
imshow(cropped_img);
In this code, we first load an image and display it using the imshow function. We then define an ROI using the imrect function and modify its position. We can get the new position using getPosition and set it using setPosition. Finally, we extract the part of the image inside the ROI using imcrop and display it using imshow.
  1 件のコメント
Jonah
Jonah 2023 年 5 月 31 日
great thank you

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

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by