Lab 11. Image Processing
Task
1 – Read about ppm and Matrix2D
-
Download a ppm file (eg. im1.ppm
or im2.ppm) or find something else over the
Internet.
Task
2 – Point Transformations
- Download the
file Invert.c to invert a ppm image plus the Makefile.
- Run the file
for several values of p (1,2,4).
- Invert only
one color channel and observe the execution.
- Derive a
program for brightening up with a double scale.
- Use the
equations recvbufR[i] =(unsigned char) min(255, recvbufR[i]*scale);.
- Derive a
program for segmentation.
- Use the
equations if(recvbufR[i]<thr) recvbufR[i]=255;elserecvbufR[i]=0;.
Task
3 – Average An Image
-
Run the program
for various sizes of the vicinity.
-
Observe if the
input image gets blur.
-
Put some noise
in an image and then average … see whether the noise
was corrected.
Task 4 – Kernel Averaging.
-
Start from the
Task 1 program.
-
Change the
average to kernelAverage e.g. unsigned
char kernelAverage(int i0, int
j0,,int n, int m, unsigned char ** a, int size, int ** kernel, int scale)
o Iterate through the pixels
o Exclude the situations when the pixel i0+i,
j0+j is not in the image e.g. if(i0+i<0 ||
i0+i>n)continue;
o Then accumulate a[i+i0][j+j0]
in a sum considering the kernel weight e.g. sum += kernel[i+1][j+1]*
a[i+i0][j+j0];
o Return sum/scale;
-
Run the
programme for various kernels:
o kernel = {{1,1,1},{1,1,1},{1,1,1}} and scale=9;
o kernel = {{1,2,1},{2,4,2},{1,2,1}} and scale=16;
o kernel = {{-1,-1,-1},{-1,8,-1},{-1,-1,-1}} and
scale=1;
o kernel = {{0,-1,0},{-1,4,-1},{0,-1,0}} and
scale=1;
o kernel = {{-1,-1,-1},{-1,9,-1},{-1,-1,-1}} and
scale=1;
o etc
Task
5 – Median Transformation
- Change the
average method to a method that returns the median value.