Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

Rotating Indexed Bitmaps?

bob_peters
Beginner
903 Views
Hi all
I have an indexedbitmap which I want to rotate using IPP, but I do not know which IPP function I should use.I tried to use ippiRotateCenter_8u_C1R, since this seemed the most suitable from what was offered. This results in a rotated bitmap, but all colours are mixed up, so the result is not usable.
Does anyone know if there is a function I could use to rotate indexed (palette) bitmapswithout converting the bitmap type first. (Or confirm to me that there is not suc function in the IPP)
Thanks already Bob
0 Kudos
7 Replies
Vladimir_Dudnik
Employee
903 Views
HI Bob,
seems you are talking about image with palette, right? You know, palettized images consist from two parts, palette (which contains info about actual color for any particular index) and array of indexes, which represents pixels (remember, actual color info is stored in palette). So, to rotate such image, you need to rotate this array of indexes, but you do not need to rotate palette itself. Note, if rotate operation will change any index value (due to interpolation, for example) you'll got unpredictable changes in color of your image. Actually it is better to convert palettized image to true color representation, rotate it, and convert it back to palletized image, but such set of operations take long time.
Regards,
Vladimir

Message Edited by vdudnik on 02-09-2005 09:52 AM

0 Kudos
bob_peters
Beginner
903 Views
Hi Vladimir
Thanks for your reply.
Indeed I am talking about palette bitmaps.
Iam working in C# and I provided the bitmapdata.scan0 as a parameter to the rotate function. I assume that that parameter is not pointing to the palette, but to the pixel data.
Please correct me if I am wrong.
IppStatus st = ippiRotateCenter_8u_C1R( bmpsrcdata.Scan0,
new IppiSize(srcBitmap.Width,srcBitmap.Height), bmpsrcdata.Stride,
new IppiRect(0,0, srcBitmap.Width,srcBitmap.Height), bmpdstdata.Scan0, bmpdstdata.Stride, new IppiRect(0,0,srcBitmap.Width,srcBitmap.Height),
angle, 0.5*srcBitmap.Width, 0.5*srcBitmap.Height, 1
);
Interpolation should also not be the problem I am facing, since all colors are mixed up, and some of the original colors do not even appear.If I rotate the mixed up bitmap agian the colors do however remain the same.
Well for now I will transfer the bitmaps to true colors, because then at least it works fine.If you just happen to know the problem please let me now. Anyhow thanks for your time already.
Kind regards Bob
p.s. GDI plus also seems to require me to transfer the image to true color. Before it can apply rotation on it.
0 Kudos
rrogojanu
Beginner
903 Views
Hello,
i don"t have any documentation with me at the moment of this reply, but here are some oppinions:
- indeed bmpSrcData.scan0 - points to the pixel data. Ifyou need the pallete of the bitmap, there is a method from Bitmap class: GetPallete() or GetPalleteData().. or smth like that.
- the colors are mixed up because of the interpolation. I think you can get better results if you use the interpolation method Nearest Neighbour. ( i know it is available for some operation, but i don"t know if it is for Rotate - i will check). The nearest neighbour method is not mixing the indexes in the image while rotating, but use the one of indexes of the corresponding neighbouring pixels. This results in a loss of quality, but at least, you have the same colors. You should decide if this approach is appropriate for you or not.
My suggestion is that:
- if the speed is more important than some artifacts that might appear in the rotated image, then you could try rotate with NearestNeighbour method.
- if quality is more important than speed, then convert the image to ARGB color image, and then rotate.
Regards and success
0 Kudos
bob_peters
Beginner
903 Views
I tried to use Nearest Neighbor and all other interpolation methods, but still it distorts all colors upon rotating. The image is not blurred, but the colours simply change. The images I use consist of simple lines, and the colours of those lines change after the first rotation. From then on they remain fixed during future rotations. So it looks like the bitmaps are erroneous, but that also seems strange, since viewing them in different paint programs and converting them to 32 bppworks ok.
0 Kudos
rrogojanu
Beginner
903 Views
maybe some of these guys could tell us if Nearest Neighbour interpolation method is altering indexes or not..
i think it should not... i did not try, though.
0 Kudos
Vladimir_Dudnik
Employee
903 Views
Hi,
yes, that's correct Nearest Neighbour interpolation should not change index values.
Regards,
Vladimir
0 Kudos
l_luo
Beginner
903 Views

We had similar problem before, we create a function ChangePalette to change the Palette entries everytime we need to display the image. It seems working fine.

If this method has any problem, please let us know. thanks!

private void ChangePalette(Bitmap bmp)

{

if( bmp.PixelFormat == PixelFormat.Format8bppIndexed )

{

ColorPalette greyPal = bmp.Palette;

int length = greyPal.Entries.Length;

for(int i = 0;i < length;i++)

greyPal.Entries = Color.FromArgb(i,i,i);

bmp.Palette = greyPal;

}

}

0 Kudos
Reply