Question

Write a matlablab code that does the following operations- The next user function should allow the...

Write a matlablab code that does the following operations-

  1. The next user function should allow the adjustment of the overall image brightness by adding or subtracting a constant by every pixel. The user should be prompted for the number to add/subtract.
  2. The next user function should allow the adjustment of the overall image contrast by multiplying a constant to every pixel. The user should be prompted for the number to multiply.
  3. The next user function should allow the adjustment of the overall image contrast by raising the value of every pixel to a constant power. The user should be prompted for the exponent.
  4. The next user function should allow the resizing of the image. The user should be prompted for the new size. (“imresize” may be helpful)  
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include "opencv2/imgcodecs.hpp"

#include "opencv2/highgui.hpp"

#include <iostream>

// we're NOT "using namespace std;" here, to avoid collisions between the beta variable and std::beta in c++17

using std::cin;

using std::cout;

using std::endl;

using namespace cv;

int main( int argc, char** argv )

{

CommandLineParser parser( argc, argv, "{@input | lena.jpg | input image}" );

Mat image = imread( samples::findFile( parser.get<String>( "@input" ) ) );

if( image.empty() )

{

cout << "Could not open or find the image!\n" << endl;

cout << "Usage: " << argv[0] << " <Input image>" << endl;

return -1;

}

Mat new_image = Mat::zeros( image.size(), image.type() );

double alpha = 1.0; /*< Simple contrast control */

int beta = 0; /*< Simple brightness control */

cout << " Basic Linear Transforms " << endl;

cout << "-------------------------" << endl;

cout << "* Enter the alpha value [1.0-3.0]: "; cin >> alpha;

cout << "* Enter the beta value [0-100]: "; cin >> beta;

for( int y = 0; y < image.rows; y++ ) {

for( int x = 0; x < image.cols; x++ ) {

for( int c = 0; c < image.channels(); c++ ) {

new_image.at<Vec3b>(y,x)[c] =

saturate_cast<uchar>( alpha*image.at<Vec3b>(y,x)[c] + beta );

}

}

}

imshow("Original Image", image);

imshow("New Image", new_image);

waitKey();

return 0;

}

​​​​​​HOPE YOU LIKED IT

PLS LIKE IT

Add a comment
Know the answer?
Add Answer to:
Write a matlablab code that does the following operations- The next user function should allow the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a code using loop and flag function in python jupitior notebook: Ask the user for...

    Write a code using loop and flag function in python jupitior notebook: Ask the user for the number of items they bought. Also ask the price of each item they bought and quantity purchased. Display the total amount they owe. Ask the user for a number n. Calculate 1+2+3+….+n. Ask the user for a number n. Calculate 1*2*3*…*n. Ask the user for number of rows (r) and columns (c). Print * for r rows and c columns. Ask the user...

  • Hello I need C++ Code For the Following: Write a function declaration for a function that...

    Hello I need C++ Code For the Following: Write a function declaration for a function that computes interest on a credit card account balance. The function takes arguments for the initial balance, the monthly interest rate, and the number of months for which interest must be paid. The value returned is the interest due. Do not forget to compound the interest—that is, to charge interest on the interest due. The interest due is added into the balance due, and the...

  • Write a program that will ask the user for a decimal number such as 18 and...

    Write a program that will ask the user for a decimal number such as 18 and prints the 16 bit binary equivalent of the number: 0000 0000 0001 0010 NOTE: Your output should be a binary string formatted by nibbles (spaces every four bits): 0000 0000 0010 1110 1010 0111 1. Ask the user for a number and store it in an int variable called “number”. 2. Find out how many bits you want to use to represent this number....

  • PAYTHON PROGRAM WITHOUT ANY FUNCTION AND METHOD A program that will allow a grocery store to...

    PAYTHON PROGRAM WITHOUT ANY FUNCTION AND METHOD A program that will allow a grocery store to keep track of the total number of bottles collected for a seven-day period. The program should allow the user to enter the number of bottles returned for each day of the seven-day period. The program will accumulate the total number of bottles returned for the 7-day period. Then calculate the amount paid out (the total bottles returned times .10 cents). The output (display) of...

  • Write a program that will do the following. The main function should ask the user how...

    Write a program that will do the following. The main function should ask the user how many numbers it will read in. It will then create an array of that size. Next, it will call a function that will read in the numbers and fill the array (fillArray). Pass the array that was made in themain function as a parameter to this function. Use a loop that will read numbers from the keyboard and store them in the array. This...

  • This task is a program framework that you should complete. The program should allow the user...

    This task is a program framework that you should complete. The program should allow the user to move a circular figure with the mouse over a drawing area. The current position of the figure is displayed continuously: Given is the main program: import javafx.scene.Scene; import javafx.application.Application; import javafx.beans.value.*; import javafx.scene.*; import javafx.scene.paint.Color; import javafx.scene.text.Text; import javafx.stage.Stage; public class Main extends Application { private DraggableCircle dc; private Text text; private void updateText() { text.setText("("+dc.getCenterX()+", "+dc.getCenterY()+")"); } @Override public void start(final Stage...

  • Your program will ask the user to enter the amount of money they want to borrow,...

    Your program will ask the user to enter the amount of money they want to borrow, the interest rate, and the monthly payment amount. Your program will then determine how many months it will take to pay off that loan, what the final payment amount will be, and how much interest was paid over that time. If the monthly payment amount isn't high enough to pay off more than one month's interest, your program should notify the user what the...

  • Create a CodeBlocks project "HW 9" Write the code to ask the user to enter the...

    Create a CodeBlocks project "HW 9" Write the code to ask the user to enter the size of an array. Then create an integer array of that exact size. Ask the user to enter a maximum value and then write a loop to fill the array with random numbers with value in the range of 1 to the maximum value. For example, if the maximum value is 100, random numbers must have value 1 to 100 inclusive. Input size of...

  • Write a C++ program to solve: The completed program should include the following: —Program input and...

    Write a C++ program to solve: The completed program should include the following: —Program input and output —Allow the user to input the starting, stopping and increment values for the insulation thickness and the air temperature. Also, at the end of the program, provide an opportunity for the user to use the program again without having to re-execute the program (ie. Ask them if they want to use the program again). —your program must find and output the value of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT