Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Changing color/transparency of certain image pixels
QtWS25 Last Chance

Changing color/transparency of certain image pixels

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 579 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jay_Ladhad
    wrote on last edited by
    #1

    My program calculates certain points through a mathematical function and then create symmetrical pattern with the data of those particular image points. When I want to display the user which pixels are being selected the program is unable to change the color/transparency of that image on the original image itself. Here is the code:

    void Interface::updateImageDataGraph()
    {
        QRgb value;
        QImage original(imageSetPath + "/" + openImageName);
        original.load(imageSetPath + "/" + openImageName);
        original = QImage(original.width(), original.height() , QImage::Format_ARGB32);
        for(int i=0; i<original.height(); i++){
            QRgb *line = (QRgb *)original.scanLine(i);
            for(int j=0; j<original.width(); j++){
                QRgb pixelData = line[j];
                unsigned int red = qRed(pixelData);
                unsigned int green = qGreen(pixelData);
                unsigned int blue = qBlue(pixelData);
                value = qRgba(red, green, blue, 127);
                original.setPixel(j,i, value);
            }
        }
        float numberOfPixels = selectedPixelX.size();
        qDebug()<<"number of pixels:"<<numberOfPixels<<"\n";
        for(float i= 0; i< numberOfPixels; i++){
            QRgb pixelData = original.pixel(selectedPixelX[i], selectedPixelY[i]);
            unsigned int red = qRed(pixelData);
            unsigned int green = qGreen(pixelData);
            unsigned int blue = qBlue(pixelData);
            //qDebug()<<"red:"<<red<<"blue:"<<blue<<"green:"<<green<<"\n";
            value = qRgba(red+50, green+50, blue+50, 256);
            original.setPixel(selectedPixelX[i],selectedPixelY[i], value);
        }
    
        imagePixmap.convertFromImage(original);
        imagePixmap = imagePixmap.scaledToHeight(previewSize);
        imageLabel->setPixmap(imagePixmap);
        prevDataSeries->replace(imageDataSeries->pointsVector());
    }
    

    Thanks for helping.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Can you show what you get and what you expect to get ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      J 2 Replies Last reply
      0
      • SGaistS SGaist

        Hi,

        Can you show what you get and what you expect to get ?

        J Offline
        J Offline
        Jay_Ladhad
        wrote on last edited by
        #3

        @SGaist hey I am unable to upload images to the forum, I get an error saying something went wrong while parsing server response. Is there any other way I could share the image with you?

        1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          Can you show what you get and what you expect to get ?

          J Offline
          J Offline
          Jay_Ladhad
          wrote on last edited by
          #4

          @SGaist
          alt text

          Okay so got the image uploaded. My intention is to plot that scatterplot on the image itself. So I was thinking that I got the scatterplots points then select those points on the image and convert the pixel color of those particular pixel as it would be easier for the user to figure out which part of the pictures are being selected. But I am unable to see any changes on the images.

          Could you guide to as to what is wrong in my code or is there a more efficient way to get it done.

          Thanks.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved