Image:
- An image is a two-dimensional (2-D) array of pixels.
- There are mainly two types of Image.
- R-G-B Channel Image: The R-G-B Images are formed by three primary channel called a color image. Red, Green and Blue are three channels in a color image.
- Single Channel Image: Monochrome Image that has pixel's intensity ranging from 0 to 255 is called Single Channel Image.
Example:
![]() |
| Figure 1. A Monochrome Image |
GIMP Image Editor: How to edit images into Portable Grey Map
(PGM) OR Monochrome Image ?
- GIMP: GNU Image Manipulation Program.
- GIMP Image Editor is a Free and Open Source Image Editor. click here to download and install.
- It is used for converting images into a PGM Extension.
Different Type of Image Extension:
JPEG -> Joint Photographic Experts Group
PNG -> Portable Network Graphics
XCF -> eXperimental Computing Facility
PGM -> Portable Gray Map
-> In image processing technique, we have to take input as an image. So, the most efficient extension for input image is the ".PGM" extension image.
-> The ".pgm" extensible Images are editable in a text editor.
-> The ".xcf, .png, .jpeg" extensible images are not editable in a text editor.
-> ASCII: American Standard Code for Information Interchange.
Process of Converting Images into a PGM Image:
-> Download the GIMP File -> Install.
-> Download image -> Save Download Image -> "Right Click" on saving image -> go to "Open with" and -> click on "GIMP Image Editor" -> Go to the "file" in open image -> Click on "save as..." -> Go to top and Change the Name: of the file extension into "pgm" -> Go to right bottom corner, click "Save" -> Click "Take me to the Export dialog" -> Go to Right bottom corner and click "Export" -> Choose "ASCII" -> Export.
Image Contrast Stretching using C-Programming.
Contrast Stretching in Image Processing:
- It is an image processing technique for low-contrast images.
- The low-contrast images can result from poor illumination and wrong setting of a lens aperture during image acquisition.
- Contrast stretching is a process that expands the range of intensity levels in an image.
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
void main()
{
int i,j,row,col,max,pix,v=0,max1=0,min=1000;
char c[10],a[100];
FILE *p,*q;
p=fopen("cot.pgm","r"); /* "cot.pgm" is a low contrast Input Monochrome Image */
fscanf(p,"%s\n", c);
fscanf(p,"%[^\n]\n", a);
fscanf(p,"%d %d\n", &col ,&row);
fscanf(p,"%d\n",&max);
int m[row][col],m1[row][col],m2[256];
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
fscanf(p,"%d\n",&pix);
m[i][j]=pix;
if(max1<pix)
max1=pix;
if(min>pix)
min=pix;
}
}
printf("%d %d\n", max1,min);
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
m[i][j]=((255*(m[i][j]-min)/(max1-min)));
}
}
/* "d31.pgm" is a high contrast output Monochrome Image */
q=fopen("d31.pgm","w");
fprintf(q,"%s\n",c);
fprintf(q,"%s\n",a);
fprintf(q,"%d %d\n", col, row);
fprintf(q,"%d\n",max);
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
pix=m[i][j];
fprintf(q,"%d\n",pix);
}
}
fclose(p);
fclose(q);
}

No comments:
Post a Comment