필터 지우기
필터 지우기

problem with output of imrotate function.

조회 수: 2 (최근 30일)
fred bnm
fred bnm 2018년 5월 25일
편집: sparrow Jr 2018년 5월 26일
Hi, after using imrotate function, why center of object is changing. this problem is appear by obtain center of object before and after rotation. please guide me how to rotate image without changing coordination of center's object. original image:
output after rotation:
clc;clear;
img = imread('ms0.jpg');
degree = 45;
img1 = imrotate(img,-degree,'crop');
prob1 = regionprops(img,'centroid');
prob2 = regionprops(img1,'centroid');
img_center = prob1.Centroid;
img1_center = prob2.Centroid;
img_center = round(img_center);
img1_center = round(img1_center);
fprintf('center before rotation is : ( %d , %d ) \n.',img_center(1),img_center(2));
fprintf('center after rotation is : ( %d , %d ) \n.',img1_center(1),img1_center(2));

채택된 답변

Image Analyst
Image Analyst 2018년 5월 25일
imrotate() rotates about the center of the center of the image. Your blob is not at the center of the image so it will move. Perhaps you should crop your image if you want it to be at the center of an image.
  댓글 수: 3
Image Analyst
Image Analyst 2018년 5월 26일
See my Image Segmentation Tutorial to learn how you can call regionprops() to crop out the bounding box of your blob https://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862&sort=downloads_desc
props = regionprops(binaryImage, 'BoundingBox');
croppedImage = imcrop(binaryImage, props.BoundingBox);
imrotate(croppedImage, angle);
sparrow Jr
sparrow Jr 2018년 5월 26일
편집: sparrow Jr 2018년 5월 26일
Hello, Sir.. Thank you so much for your comment in my thread. I would like to ask you further questions about matlab. Would you mind if I send you an email? Iam so sorry for my comment here.
Best regard, Sparrow.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by