Re: imrotate



nazih ouwayed wrote:


Hi,
I tried to rotate a square image using imrotate command.I found
Matlab padding the corners of the rotated image with black pixels.
Does anyone know how to delete the black pixels or replace them by
white pixels?

thank you by advance,
Nazih,


Hi,

It's possible that I've misunderstood your problem, but if you mean
what I think you mean, then "deleting" the black (i.e. zero-valued)
pixels that appear when MATLAB rotates an image doesn't make any
sense. The image "box" still has to remain rectangular with edges
parallel to the screen, and there will always be some empty space
near the corners after rotation (and if the rotated image is of the
same size, the information that goes off the image boundaries gets
lost). The only exception is when the rotation is a multiple of 90
degrees, but that's easily understood.
If you want to change these corner region pixels to white, then
here's a simple trick:

Suppose L is a uint8 grayscale image that you want to rotate, say by
20 degrees. I assume you don't want to lose any image information, so
the final image will be larger than the original one. White "is" 255.

Perform the following steps
I = ones(size(L));
Lr = imrotate(L, 20);
Ir = imrotate(I, 20);
Lr(Ir==0) = 255;

Hope that helps
.



Relevant Pages

  • Re: Graphics Help TranslateTransform and RotateTransform
    ... To avoid all this I would rotate ... around the center of the image and translate to the desired co-ordinates, ... height in inches and not pixels, the following should get you started. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: imrotate
    ... Matlab padding the corners of the rotated image with black ... pixels that appear when MATLAB rotates an image doesn't make any ... Suppose L is a uint8 grayscale image that you want to rotate, ... I assume you don't want to lose any image information, ...
    (comp.soft-sys.matlab)
  • Re: WM5 - Bitmap Rotation
    ... and use DirectX 3D to rotate and scale it. ... you're going to rotate the bitmap by 90, 180 or 270 degrees, because ... pixels from the original bitmap point to the same pixel on the ...
    (microsoft.public.pocketpc.developer)
  • Re: New scanner
    ... > instead of spending ages alligning the paper, scan it in any old how, then ... > rotate the image in an image editing program using the lines of the stave ... multiple of 90 degrees the computer will have to make up the new pixels ...
    (uk.comp.homebuilt)
  • Re: Screen Rotation on PXA270
    ... I set ANGLE to 90 and the screen did rotate by 90 degrees but the aspect ... the rotated screen was an image 240 pixels across the available 320 pixels ... display) and 80 lines of pixels missing off the bottom of the screen. ... Has anyone successfully rotated a native portrait mode display to landscape ...
    (microsoft.public.windowsce.embedded)