adding two images

#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <sstream>

using namespace std;
using namespace cv;


/************************************************************************
*  blending two images with the same size                                                              
/************************************************************************/                                                                  
int main(int argc, char* argv[]) {
  
	double alpha = 0.5;
	double beta;
	double input;

	// Ask the user enter alpha
	cout << " Simple Linear Blender " << endl;
	cout << "-----------------------" << endl;
	cout << "* Enter alpha [0-1]: ";
	cin  >> input;

	if (input > 0.0 && input < 1.0) {

		alpha = input;
		beta = 1 - alpha; 
	}

	Mat image1 = imread("marais.jpg");
	Mat image2 = imread("dog.jpg");
	Mat result;


	if (image1.data && image2.data) {

		if (image1.size() == image2.size()) {

			addWeighted(image1, alpha, image2, beta, 0.0, result);
		}
		else {
			cout << " the size of the two images is not the same!" << endl;
			return -1;
		}
	}
	else {

		cout << "the error of loading images!" << endl;
		return -1;
	}

	imshow("Blending image", result);

	waitKey(0);

	return 0;
}


A random number of Rabbit images ranging from 1 to 10 are displayed for each operand and the user is expected to enter the values of the two operands and the result of adding the two operands, in the given text fields. When the user clicks on the button ‘Check!’, one of two things can happen: Case 1: all three input values are correct i) the text changes to ‘"Correct! Have another go?"’. ii) the number of Rabbit images displayed for each of the two operands changes. See Figure 2 for an example. iii) the three text fields are reset (i.e. they are made empty). 2/5 Case 2: at least one of the input values entered is incorrect i) the text changes to ‘Wrong! Try again!’. ii) the number of Rabbit images displayed does NOT change. iii) the text fields do NOT change.Implement SumItUp as a Java application. You application must satisfy ALL the specific requirements given below: a) The title of the top-level container must be ‘Welcome to SumItUp!’. b) The initial text should be ‘Enter two operands, result and click on 'Check!'’. See Figure 1. c) There should be no more than 4 Rabbit images per row. See Hint 1. d) The text fields should be wide enough to display at least TWO characters. e) The button ‘Check!’ must not resize when the GUI is resized. See Hint 2 and Figure 3. f) The ‘plus sign’ icon should appear vertically centered between the two sets of Rabbit images and must not resize when the GUI is resized. See Hint 2 and Figure 3. g) When first launched and whenever a correct answer is given, the number of displayed Rabbit images for each operand should change to any number between 1 and 10 (inclusive). See Hint 3 and Hint 4. Note: It is possible for the next number(s) to be the same as the current number(s). h) Nothing should happen if the user clicks the ‘Check!’ button while at least one of the text fields are empty, i.e. no errors should be thrown in this case. Note: You can assume that only a numeric value will be entered into the text fields.
06-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值