フィルターのクリア

How to create fixed rectangle and crop it?

4 ビュー (過去 30 日間)
Rashidul Alim Anik
Rashidul Alim Anik 2022 年 3 月 15 日
コメント済み: DGM 2022 年 3 月 16 日
I want a fixed 257x257 rectangle and want to crop according to the rectangle of my image.What is the code would be?
  1 件のコメント
KSSV
KSSV 2022 年 3 月 15 日
Read about imcrop.

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

採用された回答

yanqi liu
yanqi liu 2022 年 3 月 16 日
img = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/927339/image.jpeg');
figure; imshow(img, []);
h = imrect(gca, [1 1 257 257]);
title('please move the rect');
% now you can set the rect
pos = wait(h);
hold on; rectangle('position', pos, 'EdgeColor', 'g', 'LineWidth', 2)
img2 = imcrop(img, round(pos));
figure; imshow(img2, []);
  1 件のコメント
DGM
DGM 2022 年 3 月 16 日
You can just do imcrop(img) directly for interactive cropping. If you want to preserve the rect parameter for later, you can do
[croppedimg croprect] = imcrop(img);

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by