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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 08:00
Someone with this coz i don’t really know what i can choose, just pick whatever u want. homework - you need to choose a website that you like or use frequently. you must visit the website and discuss 6 different features/parts/aspects of the website that you think makes it good. (100 words)
Answers: 2
question
Computers and Technology, 22.06.2019 09:30
What are the steps involved in accepting all the changes in a document? arrange these in order click edit. click accept or reject. click changes. click accept all.
Answers: 1
question
Computers and Technology, 22.06.2019 21:30
How do you take a green screen out of the video while editing?
Answers: 2
question
Computers and Technology, 24.06.2019 08:00
Can someone work out the answer as it comes up in one of my computer science exams and i don't understand the cryptovariables
Answers: 1
You know the right answer?
For this part of the programming checkpoint, you need to write a segmentation method within the Pict...
Questions
question
Mathematics, 26.06.2019 06:50
question
Social Studies, 26.06.2019 07:00
Questions on the website: 13722360