Class Transform
- java.lang.Object
-
- edu.illinois.cs.cs125.mp4.lib.Transform
-
public class Transform extends java.lang.Object
A class that runs implements several simple transformations on 2D image arrays.- See Also:
- MP4 Documentation
-
-
Constructor Summary
Constructors Constructor Description Transform()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static RGBAPixel[][]
expandHorizontal(RGBAPixel[][] originalImage, int amount)
Expand in the horizontal axis around the image center.static RGBAPixel[][]
expandVertical(RGBAPixel[][] originalImage, int amount)
Expand in the vertical axis around the image center.static RGBAPixel[][]
flipHorizontal(RGBAPixel[][] originalImage)
Flip the image on the horizontal axis across its center.static RGBAPixel[][]
flipVertical(RGBAPixel[][] originalImage)
Flip the image on the vertical axis across its center.static RGBAPixel[][]
greenScreen(RGBAPixel[][] originalImage)
Remove a green screen mask from an image.static RGBAPixel[][]
rotateLeft(RGBAPixel[][] originalImage)
Rotate the image left by 90 degrees around its center.static RGBAPixel[][]
rotateRight(RGBAPixel[][] originalImage)
Rotate the image right by 90 degrees around its center.static RGBAPixel[][]
shiftDown(RGBAPixel[][] originalImage, int amount)
Shift the image down by the specified amount.static RGBAPixel[][]
shiftLeft(RGBAPixel[][] originalImage, int amount)
Shift the image left by the specified amount.static RGBAPixel[][]
shiftRight(RGBAPixel[][] originalImage, int amount)
Shift the image right by the specified amount.static RGBAPixel[][]
shiftUp(RGBAPixel[][] originalImage, int amount)
Shift the image up by the specified amount.static RGBAPixel[][]
shrinkHorizontal(RGBAPixel[][] originalImage, int amount)
Shrink in the horizontal axis around the image center.static RGBAPixel[][]
shrinkVertical(RGBAPixel[][] originalImage, int amount)
Shrink in the vertical axis around the image center.
-
-
-
Method Detail
-
shiftLeft
public static RGBAPixel[][] shiftLeft(RGBAPixel[][] originalImage, int amount)
Shift the image left by the specified amount.Any pixels shifted in from off screen should be filled with FILL_VALUE. This function does not modify the original image.
- Parameters:
originalImage
- the image to shift to the leftamount
- the amount to shift the image to the left- Returns:
- the shifted image
-
shiftRight
public static RGBAPixel[][] shiftRight(RGBAPixel[][] originalImage, int amount)
Shift the image right by the specified amount.Any pixels shifted in from off screen should be filled with FILL_VALUE. This function does not modify the original image.
- Parameters:
originalImage
- the image to shift to the rightamount
- the amount to shift the image to the right- Returns:
- the shifted image
-
shiftUp
public static RGBAPixel[][] shiftUp(RGBAPixel[][] originalImage, int amount)
Shift the image up by the specified amount.Any pixels shifted in from off screen should be filled with FILL_VALUE. This function does not modify the original image.
- Parameters:
originalImage
- the image to shift upamount
- the amount to shift the image up- Returns:
- the shifted image
-
shiftDown
public static RGBAPixel[][] shiftDown(RGBAPixel[][] originalImage, int amount)
Shift the image down by the specified amount.Any pixels shifted in from off screen should be filled with FILL_VALUE. This function does not modify the original image.
- Parameters:
originalImage
- the image to shift downamount
- the amount to shift the image down- Returns:
- the shifted image
-
rotateLeft
public static RGBAPixel[][] rotateLeft(RGBAPixel[][] originalImage)
Rotate the image left by 90 degrees around its center.Any pixels rotated in from off screen should be filled with FILL_VALUE. This function does not modify the original image.
- Parameters:
originalImage
- the image to rotate left 90 degrees- Returns:
- the rotated image
-
rotateRight
public static RGBAPixel[][] rotateRight(RGBAPixel[][] originalImage)
Rotate the image right by 90 degrees around its center.Any pixels rotated in from off screen should be filled with FILL_VALUE. This function does not modify the original image.
- Parameters:
originalImage
- the image to rotate right 90 degrees- Returns:
- the rotated image
-
flipVertical
public static RGBAPixel[][] flipVertical(RGBAPixel[][] originalImage)
Flip the image on the vertical axis across its center.This function does not modify the original image. It should also not generate any new filled pixels.
- Parameters:
originalImage
- the image to flip on its vertical axis- Returns:
- the flipped image
-
flipHorizontal
public static RGBAPixel[][] flipHorizontal(RGBAPixel[][] originalImage)
Flip the image on the horizontal axis across its center.This function does not modify the original image. It should also not generate any new filled pixels.
- Parameters:
originalImage
- the image to flip on its horizontal axis- Returns:
- the flipped image
-
shrinkVertical
public static RGBAPixel[][] shrinkVertical(RGBAPixel[][] originalImage, int amount)
Shrink in the vertical axis around the image center.An amount of 2 will result in an image that is half its original height. An amount of 3 will result in an image that's a third of its original height. Any pixels shrunk in from off screen should be filled with FILL_VALUE. This function does not modify the original image.
Note that this function is not tested by the test suite. You are free to complete it to enable shrink in the web interface, but it will not affect your score.
- Parameters:
originalImage
- the image to shrinkamount
- the factor by which the image's height is reduced- Returns:
- the shrunken image
-
expandVertical
public static RGBAPixel[][] expandVertical(RGBAPixel[][] originalImage, int amount)
Expand in the vertical axis around the image center.An amount of 2 will result in an image that is twice its original height. An amount of 3 will result in an image that's three times its original height. This function does not modify the original image. It should also not generate any new filled pixels.
Note that this function should not modify the canvas size. Pixels within the original image should be expanded, but the canvas size should remain unchanged. Some pixels will end up off screen, which is fine.
- Parameters:
originalImage
- the image to expandamount
- the factor by which the image's height is increased- Returns:
- the expanded image
-
shrinkHorizontal
public static RGBAPixel[][] shrinkHorizontal(RGBAPixel[][] originalImage, int amount)
Shrink in the horizontal axis around the image center.An amount of 2 will result in an image that is half its original width. An amount of 3 will result in an image that's a third of its original width. Any pixels shrunk in from off screen should be filled with FILL_VALUE. This function does not modify the original image.
Note that this function is not tested by the test suite. You are free to complete it to enable shrink in the web interface, but it will not affect your score.
- Parameters:
originalImage
- the image to shrinkamount
- the factor by which the image's width is reduced- Returns:
- the shrunken image
-
expandHorizontal
public static RGBAPixel[][] expandHorizontal(RGBAPixel[][] originalImage, int amount)
Expand in the horizontal axis around the image center.An amount of 2 will result in an image that is twice its original width. An amount of 3 will result in an image that's three times its original width. This function does not modify the original image. It should also not generate any new filled pixels.
Note that this function should not modify the canvas size. Pixels within the original image should be expanded, but the canvas size should remain unchanged. Some pixels will end up off screen, which is fine.
- Parameters:
originalImage
- the image to expandamount
- the factor by which the image's width is increased- Returns:
- the expanded image
-
greenScreen
public static RGBAPixel[][] greenScreen(RGBAPixel[][] originalImage)
Remove a green screen mask from an image.This function should remove primarily green pixels from an image and replace them with transparent pixels (FILL_VALUE), allowing you to achieve a green screen effect. Obviously this function will destroy pixels, but it does not modify the original image.
- Parameters:
originalImage
- the image to remove a green screen from- Returns:
- the image with the green screen removed
-
-