Rotate Image segment without background

7 vues (au cours des 30 derniers jours)
Malan Jayanka
Malan Jayanka le 16 Sep 2016
Commenté : Image Analyst le 10 Fév 2018
I want to rotate image like this
I have rotated Image but I have got image like this in matlab
How to fix this problem in matlab Actually I want only rotate leaf part only not whole image. Is it posibble
  4 commentaires
Gopichandh Danala
Gopichandh Danala le 16 Sep 2016
Thanks image analyst i will do as u suggested from now..
Malan Jayanka
Malan Jayanka le 18 Sep 2016
Gopichandh Danala, Thank you for your answer. But I have a problem. When the whole image was rotated, that image was rotated and leaf part became small. But here I want to maintain the leaf size as same as the original image. Is this possible in matlab?

Connectez-vous pour commenter.

Réponse acceptée

Gopichandh Danala
Gopichandh Danala le 16 Sep 2016
A simple trick is to change all the pixels other than the segment to a white background in your case.
I cropped your main image as u didn't post original image
and sample code is here:
leaf = imread('leaf.jpg');
figure, imshow(leaf, []);
rotateImg = imrotate(leaf,45,'crop'); % rotate by 45 or 315 degrees
figure, %imshow(rotateImg);
subplot(1,2,1)
imshow(rotateImg, [min(min(rotateImg(:))) max(max(rotateImg(:)))]);
newrotateImg = rotateImg;
newrotateImg(newrotateImg == 0) = 255; % make all 0 pixels to 255..
subplot(1,2,2)
imshow(newrotateImg, [min(min(newrotateImg(:))) max(max(newrotateImg(:)))]);
Hope it helps.
  12 commentaires
Busy Bee
Busy Bee le 10 Fév 2018
what if the image segment that I want to rotate is itself made of black pixels?
Image Analyst
Image Analyst le 10 Fév 2018
What if you showed it to us?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Image Segmentation and Analysis dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by