Results 1 to 10 of 10

Thread: QImage pixelIndex resize color Table prolem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QImage pixelIndex resize color Table prolem

    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

  2. #2
    Join Date
    Mar 2018
    Posts
    5
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QImage pixelIndex resize color Table prolem

    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.

  3. #3
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QImage pixelIndex resize color Table prolem

    Hi,

    Let's imagine that your image is a 8 bit image. You can create a color table like this:

    Qt Code:
    1. for (int i=0; i<255; i++)
    2. 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:
    1. for (int i=0; i<255; i++)
    2. 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

  4. The following user says thank you to ^NyAw^ for this useful post:

    johny333 (8th March 2018)

  5. #4
    Join Date
    Mar 2018
    Posts
    5
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QImage pixelIndex resize color Table prolem

    Hi,

    Ok, so is not possible reduce color table and indexes in image. This is answer for my question.

    Thanks.

  6. #5
    Join Date
    Apr 2012
    Location
    Romania
    Posts
    22
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QImage pixelIndex resize color Table prolem

    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:
    1. for(int index = 0; index < 255) {
    2. if(index < 100) {
    3. colortable[i] = QRgb(50, 50, 50);
    4. }
    5. if(index >= 100 && index < 255) {
    6. colortable[i] = QRgb(125, 125, 125);
    7. }
    8. }
    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

Similar Threads

  1. Problem with pixelIndex in QImage
    By danilodsp in forum Newbie
    Replies: 2
    Last Post: 17th September 2011, 06:14
  2. QImage::pixelIndex out of range warning
    By danics in forum Qt Programming
    Replies: 1
    Last Post: 10th March 2010, 12:54
  3. color table with QGradient and QImage
    By desch in forum Qt Programming
    Replies: 3
    Last Post: 22nd May 2008, 10:32
  4. Replies: 9
    Last Post: 21st June 2007, 10:27
  5. color table for qimage
    By kernel_panic in forum Qt Programming
    Replies: 4
    Last Post: 5th April 2007, 17:44

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.