You only need one copy of the array in your program, not 5. The first index to the array will be determined by the set number (mod 9) and the second index will be determined by the pixel's luminance.
small world. thought i'd google the assignment cuz idk how to do it and this comes up. did you figure out how to do it yet?
Better delete this b4 the professor googles the assignment and finds out
does anyone remember how to do this with an image, I have started to do a similar issue but cant finish it, here is my code: is it similar to the old code here, and can anyone help me work on it.
public void grayscalewithLuminance()
Pixel  pixelArray = this.getPixels();
Pixel pixel = null;
int luminance = 0;
double redValue = 0;
double greenValue = 0;
double blueValue = 0;
//loop through all the pixels
for (int i=0; i < pixelArray.length; i++)
//get the current pixel
pixel = pixelArray[i];
//get the corrected red,green, and blue values
redValue = pixel.getRed() * 0.299;
greenValue = pixel.getGreen() * 0.587;
blueValue = pixel.getBlue() * 0.114;
//compute the intensity of the pixel (average value)
luminance = (int) (redValue + greenValue + blueValue);
//set the pixel color to the new color
this is the other part to my code
any help will be appreciatedCode:
public Picture componentLayout()
//Declare new picture
Picture newPicture = new Picture(this.getWidth() * 2, this.getHeight()
Pixel sourcePixel = null;
Pixel targetPixel = null;
int targetX = 0;
int targetY = 0;
// the redvalue of each pixel in the image
// The bluevalue of each pixel in the image
int blueValue = 0;
// the greenvalue of each pixel in the image
Pixel pixelObj = null;
Pixel pixelArray = this.getPixels();
for (int index = 0; index < pixelArray.length; index++)
// Get the pixel at the current index from the array of pixels.
pixelObj = pixelArray[index];
// Get the blue value at the pixel.
blueValue = pixelObj.getBlue();
// Get the red value at the pixel.
redValue = pixelObj.getRed();
// Get the green value at the pixel
greenValue = pixelObj.getGreen();
int range = 0;
//loops through x
for (int x= 0; x < this.getWidth(); x++)
//loops through y
for (int y = 0; y < this.getHeight(); y++)
//source pixels retrieved
sourcePixel = this.getPixel(x,y);
if (redValue > blueValue && redValue>greenValue)
targetX = this.getWidth()*2;
Moderator Edit: Code tag corrected
you borrowed two pieces of code from two different places... they don't really fit together at all :(
well my ultimate goal is to separate the pixels so the pixels with mostly gray are in the top left corner, the pixels with the most red are the in the top right, and the pixels with the most green in the bottom left, and most blue in the bottom right, I found the code for luminance and thought it would help with the ultimate goal, as well as figuring out the pixels with the max gray. any ideas on I can merge these to form my goal. I am getting soo frustrated with this.