Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6743577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:58:40+00:00 2026-05-26T11:58:40+00:00

I am creating a simple image processing application using OpenCV / Qt and I

  • 0

I am creating a simple image processing application using OpenCV / Qt and I am looking for a way to optimize the code that I have created (https://github.com/krslynx/ImageProcessingApplication). Currently, each time a slider is moved in the application the respective method is called which alters the image, for example:

/** ActionEvent for the brightness slider moving */
void MainWindow::on_brightnessSlider_sliderMoved() {
                          //setBrightness is the method called
    updateImage(ui->pixmap, setBrightness(this->image, ui->brightnessSlider->value());
}

Where the updateImage method updates the QLabel (ui->pixmap) which stores the image. This presents a problem as the cv::Mat image / this->image is the raw image which is called in each ActionEvent thus if the Brightness Slider is moved, then the Contrast Slider is moved, the brightness changes won’t be persisted due to the sliders depending on this->image rather than the set QLabel pixmap. I ‘solved’ this issue by using the following code:

/** ActionEvent for the brightness slider moving */
void MainWindow::on_brightnessSlider_sliderMoved() {

    cv::Mat result = this->image;

    result = setBrightness(result, ui->brightnessSlider->value());
    result = setContrast(result, ui->contrastSlider->value());
    result = setSharpness(result, ui->sharpnessSlider->value());
    result = setZoom(result, ui->zoomSlider->value());

    updateImage(ui->pixmap, result);
}

While this code gives the exact visual effect I need, it means that each action event needs to have ALL of the above code within it (and I need to keep adding code for each new feature I add), and I am re-processing things that I’ve already processed. When dealing with a larger image, which has had all of the sliders moved it can sometimes take over 1.1 seconds to process.

I tried to instead change the global image this->image by reference, and even create another global for the altered image however I ran into problems where when I moved the brightness/contrast/sharpness/zoom slider up/down, it would change far too vigorously.

Any pointers would be greatly appreciated! I am fairly new to C++!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:58:40+00:00Added an answer on May 26, 2026 at 11:58 am

    Make a separate function that updates the image based on the sliders’ values. For example have a function like this

    void MainWiondow::generic_sliderMoved() {
        cv::Mat result = this->image;
    
        result = setBrightness(result, ui->brightnessSlider->value());
        result = setContrast(result, ui->contrastSlider->value());
        result = setSharpness(result, ui->sharpnessSlider->value());
        result = setZoom(result, ui->zoomSlider->value());
    
        updateImage(ui->pixmap, result);
    }
    

    You could set each slider’s action event to be this function. If some sliders need some more functionality beyond this then you can make a different action event function that calls that function like this:

    /** ActionEvent for the brightness slider moving */
    void MainWindow::on_brightnessSlider_sliderMoved() {
        /* brightness slider specific code */
    
        generic_sliderMoved();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a simple application with Django. I realized that I am doing
I am creating a simple application using the MVC design pattern where my model
I have started creating a simple product image carousel. It basically comprises of 3
We're currently creating a simple application for image manipulation in Silverlight, and we've hit
I am using Flex 4. I have created an image gallery with TileList When
I have created an ActiveX control using C++. I use Visual Basic code to
I'm creating what should be a simple image slider/flipper. I have a set of
I'm creating a simple HTML page that has an image upload. That image then
I'm creating a simple form that takes a referal code and email address, stores
So, using IE as my browser, I have a simple link... <a href=test.jpg>Image Link</a>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.