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...

  • python: def functionSolver(function: callable)->str You will be given a function as a parameter, the function you...

    python: def functionSolver(function: callable)->str You will be given a function as a parameter, the function you are given only accepts two number parameters and produces a float value. It is your job to figure out what mathematical operation the function you are given is performing by passing it many different parameters. The possible operations the function can perform are: add, subtract, multiply, and divide. The given function will only perform a single operation, it will not change after consecutive invocations....

  • 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...

  • 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....

  • 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...

  • 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 c++ program: Many mathematical problems require the addition, subtraction, and multiplication of two matrices. Write an ADT Matrix. You may use the following class definition: const int MAX_RO...

    Write a c++ program: Many mathematical problems require the addition, subtraction, and multiplication of two matrices. Write an ADT Matrix. You may use the following class definition: const int MAX_ROWS = 10; const int MAX_COLS = 10; class MatrixType { public: MatrixType(); void MakeEmpty(); void SetSize(int rowsSize, int colSize); void StoreItem(int item, int row, int col); void Add(MatrixType otherOperand, MatrixType& result); void Sub(MatrixType otherOperand, MatrixType& result); void Mult(MatrixType otherOperand, MatrixType& result); void Print(ofstream& outfile); bool AddSubCompatible(MatrixType otherOperand); bool MultCompatible(MatrixType otherOperand);...

  • 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...

  • C++ Question Your class should support the following operations on Fraction objects: • Construction of a...

    C++ Question Your class should support the following operations on Fraction objects: • Construction of a Fraction from two, one, or zero integer arguments. If two arguments, they are assumed to be the numerator and denominator, just one is assumed to be a whole number, and zero arguments creates a zero Fraction. Use default parameters so that you only need a single function to implement all three of these constructors. You should check to make sure that the denominator is...

  • 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