ISC Practical 2027: Image Editor – Brighten an Image and Find Bright Spots (2-D Array) – Java Program
Fully solved ISC Computer Science Practical 2027 2-D array question: brighten a grayscale image (capping values at 255) and find the bright spots, pixels larger than all four neighbours. Includes a missing bright spot in CISCE’s sample output.

This is Question 2 of Sample Paper 3 from the specimen questions CISCE has released for the ISC Year 2027 Computer Science Practical (Paper 2). The concept area is Two-dimensional arrays. Below you will find the question, a plain-language explanation of the logic, an exam-ready algorithm, a fully documented Java program, the real output for every sample input, and tips for scoring the full 15 marks.
Every program on this page was compiled with JDK 21 and run on CISCE’s sample inputs, plus extra boundary inputs of the kind a visiting examiner will try.
The question
A photo-editing program stores a grayscale image with pixel values from 0 to 255, where a higher value means greater brightness. Design a class ImageEditor to accept an image of size rows × cols, where 3 ≤ rows, cols ≤ 6 (otherwise display INVALID INPUT), and perform the following tasks:
- Brighten the image: accept a brightness value b and add it to every pixel. If the result exceeds 255, store 255. Store the brightened image separately and display both images.
- Identify bright spots: a pixel is a bright spot if its value is greater than all its immediate neighbours (above, below, left and right). For a missing boundary neighbour, use 0. Display the position and value of every bright spot.
CISCE gives 3 examples with this question. Each one is shown with its output in the Output section below, so you can check your own program against it.
Note on the CISCE sample: The expected output in the CISCE document for Example 1 misses one bright spot. The pixel at Row 4, Column 1 has the value 4. Its neighbours are 1 (above), 2 (right) and two missing neighbours that count as 0, so 4 is greater than all of them. A correct program prints five bright spots, as ours does.
Understanding the problem
A double-dimensional array question about neighbours, a pattern that appears in many ISC papers (local minimum, saddle point, boundary elements).
- Keep two arrays. The question says to store the brightened image separately, and bright spots are found in the original image. Overwriting the original would change the answer.
- Clamp the value:
if (v > 255) v = 255;. Clamping below 0 as well protects you if the examiner enters a negative brightness. - The neighbour trick: write
valueAt(i, j)that returns 0 when (i, j) is outside the image. Then every cell, including corners and edges, can be tested with the same four comparisons, and you never get ArrayIndexOutOfBoundsException. - "Greater than all" is strict. In a flat image where all pixels are equal, there are no bright spots.

Algorithm [3 marks]
Write the algorithm in the planning session, in numbered steps like these. It must match your program exactly.
- Start.
- Input rows and cols. If either is less than 3 or more than 6, print "INVALID INPUT" and stop.
- Input the pixels into img[rows][cols]. If any value is outside 0 to 255, print "INVALID INPUT" and stop.
- Input the brightness value b.
- For every cell: v = img[i][j] + b; if v > 255 set v = 255; if v < 0 set v = 0; store v in bright[i][j].
- Display img and bright.
- Define valueAt(i, j) = img[i][j] if (i, j) is inside the image, else 0.
- For every cell (i, j): if img[i][j] is greater than valueAt(i − 1, j), valueAt(i + 1, j), valueAt(i, j − 1) and valueAt(i, j + 1), print "Row i + 1, Column j + 1 : value".
- If no bright spot was found, print "NONE".
- Stop.
Java program [7 marks]
The program uses a class with separate methods for each task and comments that explain every data member and the special logic. That is what the 2 documentation marks are for.
import java.util.Scanner;
/**
* ISC Practical 2027 - Sample Paper 3, Question 2
* Brightens a grayscale image stored in a 2-D array and finds its bright spots.
*/
public class ImageEditor
{
int img[][]; // original image (pixel values 0 to 255)
int bright[][]; // brightened copy
int rows, cols;
ImageEditor(int r, int c)
{
rows = r;
cols = c;
img = new int[rows][cols];
bright = new int[rows][cols];
}
// returns false if any pixel is outside 0 to 255
boolean accept(Scanner sc)
{
System.out.println("Enter the pixel values:");
boolean ok = true;
for (int i = 0; i < rows; i++)
for (int j = 0; j < cols; j++)
{
img[i][j] = sc.nextInt();
if (img[i][j] < 0 || img[i][j] > 255)
ok = false;
}
return ok;
}
// adds b to every pixel and limits the result to the range 0 to 255
void brighten(int b)
{
for (int i = 0; i < rows; i++)
for (int j = 0; j < cols; j++)
{
int v = img[i][j] + b;
if (v > 255) v = 255;
if (v < 0) v = 0;
bright[i][j] = v;
}
}
void display(int m[][])
{
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < cols; j++)
System.out.print(m[i][j] + "\t");
System.out.println();
}
}
// value of a neighbour, or 0 if the position lies outside the image
int valueAt(int i, int j)
{
if (i < 0 || j < 0 || i >= rows || j >= cols)
return 0;
return img[i][j];
}
void brightSpots()
{
System.out.println("Bright Spots");
boolean found = false;
for (int i = 0; i < rows; i++)
for (int j = 0; j < cols; j++)
{
int v = img[i][j];
if (v > valueAt(i - 1, j) && v > valueAt(i + 1, j)
&& v > valueAt(i, j - 1) && v > valueAt(i, j + 1))
{
System.out.println("Row " + (i + 1) + ", Column " + (j + 1) + " : " + v);
found = true;
}
}
if (!found)
System.out.println("NONE");
}
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.print("Rows: ");
int r = sc.nextInt();
System.out.print("Columns: ");
int c = sc.nextInt();
if (r < 3 || r > 6 || c < 3 || c > 6)
{
System.out.println("INVALID INPUT");
return;
}
ImageEditor ob = new ImageEditor(r, c);
if (!ob.accept(sc))
{
System.out.println("INVALID INPUT");
return;
}
System.out.print("Brightness value: ");
int b = sc.nextInt();
ob.brighten(b);
System.out.println("Original Image:");
ob.display(ob.img);
System.out.println("Brightened Image:");
ob.display(ob.bright);
ob.brightSpots();
}
}Variable description
Name Type Purpose
------------- --------- -------
img[][] int[][] original image
bright[][] int[][] brightened copy of the image
rows, cols int size of the image
b int brightness value added to every pixel
v int pixel value after brightening
found boolean true once a bright spot is printedOutput [3 marks]
These are the actual outputs of the program above for every example in the question:
INPUT:
Rows: 4
Columns: 3
250 5 3
6 4 7
1 9 5
4 2 240
Brightness value: 20
OUTPUT:
Original Image:
250 5 3
6 4 7
1 9 5
4 2 240
Brightened Image:
255 25 23
26 24 27
21 29 25
24 22 255
Bright Spots
Row 1, Column 1 : 250
Row 2, Column 3 : 7
Row 3, Column 2 : 9
Row 4, Column 1 : 4
Row 4, Column 3 : 240INPUT:
Rows: 3
Columns: 3
5 2 3
1 4 1
2 1 2
Brightness value: 0
OUTPUT:
Original Image:
5 2 3
1 4 1
2 1 2
Brightened Image:
5 2 3
1 4 1
2 1 2
Bright Spots
Row 1, Column 1 : 5
Row 1, Column 3 : 3
Row 2, Column 2 : 4
Row 3, Column 1 : 2
Row 3, Column 3 : 2INPUT:
Rows: 2
Columns: 7
OUTPUT:
INVALID INPUTTest it on unknown inputs
One of the 3 output marks is for correct output on inputs the examiner chooses, usually boundary cases. Our program handles these correctly:
INPUT:
Rows: 3
Columns: 3
0 0 0
0 0 0
0 0 0
Brightness value: 300
OUTPUT:
Original Image:
0 0 0
0 0 0
0 0 0
Brightened Image:
255 255 255
255 255 255
255 255 255
Bright Spots
NONEHow to score full marks on this question

- Explain the valueAt() helper in a comment. It is exactly the "special logic" the documentation mark asks you to describe.
- Print rows and columns starting from 1, as in the sample output.
- Test a brightness value larger than 255 (every pixel becomes 255) and a flat image (no bright spots).
- Keep the typed program identical to the planned one. Large differences between your planning sheet and the printout cost the 2 hard-copy marks.
Common mistakes to avoid
- Finding bright spots in the brightened image. After capping, 250 and 240 both become 255, and the results change.
- Treating the missing neighbours of corner cells as "not smaller", so corners are never bright spots.
- Using >= instead of >.
This post is part of our series that solves all 12 specimen questions for the ISC 2027 Computer Science practical, one question a day. Practise writing the algorithm and program on paper in 90 minutes before you type it. That is exactly how the exam works.
Related Posts
Continue learning with these related articles

ISC Practical 2027: College Enrolment Code Validator and Stream Report – Algorithm and Java Program
Fully solved ISC Computer Science Practical 2027 question: validate college enrolment codes made of a stream, year and serial number, give the exact reason for each rejection, auto-correct lowercase streams and prepare a stream-wise report.

ISC Practical 2027: Digital Lock Security Code Analyzer – Algorithm and Java Program
Fully solved ISC Computer Science Practical 2027 number-logic question: for a 5 to 10 digit security code, find the first and last digits, odd and even position sums, product of non-zero digits, digit frequency and classify the code as STRONG, MODERATE or WEAK.

Boolean Algebra for ISC Class 12: Laws, Canonical SOP and POS, and Simplification
ISC Class 12 Computer Science notes on Boolean algebra: all the laws and theorems, duality, De Morgan's laws, minterms and maxterms, converting to canonical SOP and POS, and step-by-step algebraic simplification with solved examples.