image cropping location problem

2 次查看(过去 30 天)
why i got diffrent location of crop when i change the image im using btw im using the same value of coordinate but the location is diffrent
  7 个评论
DGM
DGM 2021-11-21
Provide a simplified and concrete example demonstrating the problem.
Matt J
Matt J 2021-11-21
Maybe the images are not all the same size. Therefore, the cropping coordinates don't cover the same spatial region in all cases.

请先登录,再进行评论。

采纳的回答

yanqi liu
yanqi liu 2021-11-22
sir,may be use the rate,such as
clc; clear all; close all;
im = imread('cameraman.tif');
sz = [size(im, 1) size(im, 2)];
rect = round([sz(2)/2 sz(1)/2 sz(2)*0.2 sz(1)*0.3]);
im2 = imcrop(im, rect);
figure;
subplot(1, 2, 1); imshow(im);
hold on; rectangle('position', rect, 'EdgeColor', 'g', 'LineWidth', 2)
subplot(1, 2, 2); imshow(im2);
im = imread('football.jpg');
sz = [size(im, 1) size(im, 2)];
rect = round([sz(2)/2 sz(1)/2 sz(2)*0.2 sz(1)*0.3]);
im2 = imcrop(im, rect);
figure;
subplot(1, 2, 1); imshow(im);
hold on; rectangle('position', rect, 'EdgeColor', 'g', 'LineWidth', 2)
subplot(1, 2, 2); imshow(im2);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MRI 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by