Clear Filters
Clear Filters

How to rotate an image without losing any pixels?

5 views (last 30 days)
Hi, I used imrotate to rotate my hand image. I had marked the wrist points with an intensity value 100 and wrist points with intensity value 150; so that I don't loose the coordinate points after rotation. My image is:
And the resultant image I got after rotating it 21.8014 degree is this:
Two of three white dots are missing. Please suggest some solution, is there any method to preserve those points with rotated coordinates?

Answers (1)

Image Analyst
Image Analyst on 16 Apr 2015
If you use the 'nearest' option of imrotate(), there is a chance the single white dots won't copy over. If you use the default interpolated mode then, unless the white dot falls exactly on an output pixel, the white dot will land between output pixels and thus be spread over 4 pixels resulting in a lower intensity - perhaps not bright enough to notice. To avoid holes in the image imrotate basically scans the output and figures out where in the input image to pull a pixel from. This way ensures that every pixel in the output image will have a value. The other way is to scan the input image and send every input value to an output location. Doing it this way means that you will have some "holes" in the output image where no input pixels ever got assigned to. If you do this then you can be sure that your single white dots end up somewhere, but you'll have to write the code yourself, including the part where you "fill in" holes (missing pixels). No I don't have any code for this but it's easy for you to do yourself.
  4 Comments
Image Analyst
Image Analyst on 16 Apr 2015
It could be that the white dots were never the nearest pixel and so they didn't get sent over. Read carefully what I wrote above.
Nafeesath Musfira
Nafeesath Musfira on 17 Apr 2015
Sorry, but I didn't get what sending input pixels to output location means.Can you please explain?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!