Hi,
How would you expect that it will change automatically?
A RGB Pixel value (230,100,100) wich color table value must have?
Could you explain us what you are trying to do?
Hi,
How would you expect that it will change automatically?
A RGB Pixel value (230,100,100) wich color table value must have?
Could you explain us what you are trying to do?
Òscar Llarch i Galán
I trying convert image from format, that use full 256 colors to format, that use count color by me. I convert image by my own algorithm. When Image use full 256 index, compress data is for example 1000B. When Image use for example 10 index of colors, compress data is for example 200B. I will have possibility change size of compress data. This is possible when resize count index, that image use.
Hi,
Let's imagine that your image is a 8 bit image. You can create a color table like this:
Qt Code:
for (int i=0; i<255; i++) colortable[i] = QRgb(i,i,i);To copy to clipboard, switch view to plain text mode
Displaying this image you will see a gray scale image.
Using this color table
Qt Code:
for (int i=0; i<255; i++) colortable[i] = QRgb(i,0,0);To copy to clipboard, switch view to plain text mode
You will see a "red scale" image.
If you want a color table with only 10 indexes you have to create it as nobody knows wich output colors you expect to get. Finally, from Qt Docs:
"When the image is used, the color table must be large enough to have entries for all the pixel/index values present in the image, otherwise the results are undefined"
As your image is still having pixel values higher than 10, the output on the screen is undefined.
Òscar Llarch i Galán
johny333 (8th March 2018)
Hi,
Ok, so is not possible reduce color table and indexes in image. This is answer for my question.
Thanks.
Hi,
Not necessarily. You could map all the colours from an image in these 10 colours. For example, you can set colours in the form (i, i, i) which have values between 0 and 100 to be mapped to the colour defined as (50, 50, 50). Something like this:
Qt Code:
for(int index = 0; index < 255) { if(index < 100) { colortable[i] = QRgb(50, 50, 50); } if(index >= 100 && index < 255) { colortable[i] = QRgb(125, 125, 125); } }To copy to clipboard, switch view to plain text mode
So what you need to do is to decide the RGB values for these 10 colours and map all the shades of these colours to their equivalent in your 10 colours palette. Of course, this will have to be done manually (I mean you decide which shade is equivalent to which colour).
Best regards,
Sorin
Bookmarks