subject
Computers and Technology, 11.05.2021 22:30 babas97

For this part of the programming checkpoint, you need to write a segmentation method within the Picture. java class that will create an inner square segment inside a picture. This method will be called segment (int xPos, int yPos, int sWidth), which takes three parameters which are the x(xPos) and y(yPos) coordinate of the upper left corner of an inner square in addition to the width (sWidth) of the inner square that will be segmented. The method should do the following:
Check if sWidth is positive.
Check that the given sWidth is less than or equal to half of the picture’s width. The same should be checked for the height
Check that the xPos and yPos are valid so the square will be drawn within the original picture height and width. i. e., (xPos +sWidth) should be less than the picture width, and (yPos +sWidth) should be less than the picture’s height.
Iterate through every pixel in the inner square and check the RGB components as follow:
Find out which color component of a pixel has the highest value
Make the highest value the dominant color component by resetting the other color components to zero.
This method will show the selected square portion partitioned into three colors based on the dominant color component. When you think you have it right, compile your code, and use the interactions pane to test your new method. Below are some tests:
> import java. awt.*;
> Picture pic = new Picture(FileChooser. pickAFile());
> pic. segment(40,50,-200);
Error: inner square width should not be negative -200
> pic. segment(40,50,260);
Error! inner square width must be less than half the width and height.
> pic. segment(480,50,200);
Error! inner square top left should be within the picture limits
> pic. segment(150,250,200);
> pic. show();

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 01:00, ariyanna029
What is added to the < meta > tag to describe the encoding type?
Answers: 2
image
Computers and Technology, 22.06.2019 19:30, 710jonathan
The following is an excerpt from a slide presentation. today we will inverse operations solving equations using inverse operations solving inequalities using inverse operations from which part of the presentation does the slide most likely come from? a. introduction b. outline c. body d. conclusion
Answers: 1
image
Computers and Technology, 23.06.2019 06:00, 573589
What machine listens for http requests to come in to a website’s domain? a. a router b. a browser c. a server d. a uniform resource locator
Answers: 1
image
Computers and Technology, 23.06.2019 19:00, nayo2006
Acompany is hiring professionals for web designing. the firm is small with few resources. they want employees who possess problem-solving skills and can independently carry out responsibilities. which kind of employee should they select?
Answers: 2
You know the right answer?
For this part of the programming checkpoint, you need to write a segmentation method within the Pict...

Questions in other subjects:

Konu
Mathematics, 20.10.2021 01:00