Question: Is there anything wrong with allocating and deallocating thousands of Color objects, as in Grayscale (PROGRAM 3.1.4)? Program 3.1.4 Converting color to grayscale import java.awt.Color;
Is there anything wrong with allocating and deallocating thousands of Color objects, as in Grayscale (PROGRAM 3.1.4)?

Program 3.1.4 Converting color to grayscale import java.awt.Color; public class Grayscale { } public static void main(String[] args) { // Show image in grayscale. Picture picture = new Picture (args[0]); for (int col = 0; col < picture.width(); col++) { } for (int row = 0; row < picture.height(); row++) { } picture image from file col, row pixel coordinates color pixel color gray pixel grayscale Color color picture.get (col, row); Color gray = Luminance. toGray(color); picture.set(col, row, gray); picture.show();
Step by Step Solution
3.54 Rating (158 Votes )
There are 3 Steps involved in it
All programminglanguage constructs ... View full answer
Get step-by-step solutions from verified subject matter experts
