CSC1401 Controlling Pictures.


167 views
Uploaded on:
Description
CSC1401 Controlling Pictures. What we have done to date. We have adjusted pictures by composing on top of them Utilizing Turtles and utilizing Design Drawing lines, shapes and content, and additionally embeddings a photo into another picture. What might be pleasant to do. Changing hues on the photos
Transcripts
Slide 1

CSC1401 Manipulating Pictures

Slide 2

What we have done to date We have altered pictures by composing on top of them Using Turtles and utilizing Graphics Drawing lines, shapes and content, and additionally embeddings a photo into another picture

Slide 3

What might be decent to do Changing hues on the photos Red-eye diminishment Blending pictures Doing other extravagant Adobe Photoshop-like changes But this would be verging on difficult to do by essentially drawing on top of the current picture

Slide 4

The Goal Develop a simpler way to deal with changing so as to adjust our photos the photos themselves instead of composing on top of them

Slide 5

Digital Pictures Represented by pixels With a red, green, and blue quality put away for every pixel Stored in .jpg (JPEG) records International standard With lossy pressure Lossy means not all information is put away But rather what is lost isn’t that critical Compression means made littler Other arrangements for putting away advanced pictures are GIF and BMP

Slide 6

Manipulating a Picture To control a photo we have to control the pixels that roll out up the photo Improvement the red, green, or blue qualities at the Pixel is a class made at Georgia Tech Each pixel item has a red, green, and blue worth

Slide 7

Pictures have loads of Pixels How would we be able to allude to every pixel? pixel1, pixel2, pixel3, pixel4, pixel5, … Do we truly need to name every one? On a 640 x 480 picture, there are 640 x 480 = 307,200 pixels

Slide 8

How would we change a Pixel? Pixel first; first = stevepicture.getPixel(10,120);/10 alludes to the line and 120 to the segment first.setColor(Color.black);/* The book composes the code as: stevepicture.getPixel(10,100).setColor(Color.black); */Note that on the off chance that you have as of now demonstrated the photo, by conjuring: stevepicture.show(); You can bring about the photo to be upgraded by: stevepicture.repaint();

Slide 9

Pictures have bunches of Pixels How would we manage loads of information of the same sort? Utilize a cluster

Slide 10

What is an Array? 0 1 2 3 4 5 Storage for a grouping of things Of the same sort You can get to things by utilizing a file The file begins at 0 The first thing is at record 0 The last thing is at list (length – 1) Arrays know their length (have an open length field) arrayObj.length 3 7 9 2 1 5 0 1 2 3 8 3 2 6

Slide 11

But how does an exhibit help us? On the off chance that we wish to change heaps of pictures, we can utilize a circle!

Slide 12

Recall from Alice In this case, every time through the circle, the bunny jumped Note that the file variable changes from 0 to 1 to 2 to … every time through the circle. Also, we can exploit that when working with exhibits!

Slide 13

In Java Use a circle to get to a variety of pixels The first run through the circle we get to pixelArray[0] The second time through the circle we get to pixelArray[1] …

Slide 14

What Data does a Picture Object Have? A photo item has a variety of pixel questions That it read from the .JPG record It knows the photo width pictureObj .getWidth() It knows the photo tallness pictureObj .getHeight() It knows how to give back a variety of pixels Pixel[] pixelArray = pictureObj .getPixels()

Slide 15

Pixel Objects Each pixel has a red, green, and blue worth getRed(), getGreen(), getBlue() setRed(v), setGreen(v), setBlue(v) Each pixel knows the area it was in the photo object getX(), getY() You can likewise get and set the shading at the pixel getColor(), setColor(color)

Slide 16

Turning the greater part of the pixels in our photo to red – utilizing a circle Notes: We have made a counter that begins at 0, and goes up to the quantity of pixels in the photo Each pixel has its shading set to red! How might this code have looked had it been composed as a technique within the Picture class?

Slide 17

A note on Color You can either set the red, green and blue sums separately, or all together utilizing mypixel.setColor(someColor) You can make a giving so as to shade item the red, green, and blue qualities for it Color colorObj = new Color(255,10,125);

Slide 18

Predefined Colors The Color class has characterized class constants for some hues Color.red, Color.green, Color.blue, Color.black, Color.white, Color.yellow, Color.gray, Color.orange, Color.pink, Color.cyan, Color.magenta Or you can utilize every single capitalized name Color.RED, Color.BLUE, Color.BLACK, …

Slide 19

Getting and Setting Pixel Colors To get a pixel’s shading as a shading article Color color1 = pixelObj .getColor(); int red = color1.getRed(); int green = color1.getGreen(); int blue = color1.getBlue(); To set a pixel’s shading utilizing another shading item red = 20; green = 30; blue = 100; Color color2 = new Color(red,green,blue); pixelObj.setColor(color2);

Slide 20

Changing Pixel Colors There are two approaches to change the shade of a pixel in a photo Set the red, green, and blue values independently pixelObj.setRed(value), pixelObj.setGreen(value), pixelObj.setBlue(value), Or set the shading pixelObj.setColor(colorObj) But, you won’t see any adjustment in the photo Until you request that it repaint: pictureObj.repaint(); Or you conjure the show system

Slide 21

Summary Pictures have pixels You can change the photo by changing the pixels\' shade Arrays let you store and recover estimations of the same sort utilizing a file You can approach a photo for it’s width, stature, and a variety of pixels You can get and set the shade of a pixel

Slide 22

Assignment Read Media Computation Chapter 4 – we’ll be covering while circles and for-every circles one we

Recommended
View more...