Thursday, 7 July 2022

GIMP Image Editor

GIMP Image Editor:     How to edit images into PGM ?

  • 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

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.

Tuesday, 5 July 2022

Image Processing using C-Programming

Image

  • An image is a two-dimensional (2-D) array of pixels.
  • There are mainly two types of Image.
  1. 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.
  2. Single Channel Image: Monochrome Image that has pixel's intensity ranging from 0 to 255 is called Single Channel Image. 

Example:


Monochrome Image
Figure 1. A Monochrome Image












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");
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)));
}
}

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);



Monday, 4 July 2022

Generic Pointer in C

Void Pointer or Generic Pointer (void *) in C


Pointers: 


-> A pointer is a derived data type in C-Programming.
-> It builds from one of the fundamental data types (int, float, char, and double).
-> The declaration of a pointer variable is as follows: data_type *pointer_name

Example 1:      int *P;
                         float *x;

-> Ampersand Symbol ( & ) in C-Programming represents the "address of" operator.    

Example 2:      int quantity;
                        int *P; 
                        P = &quantity;     

-> In this syntax, integer, pointer variable 'P' store the address of an integer variable quantity

Example 3:        float rate;
                           int *P;
                           P = &rate

-> The syntax given in Example 3 is wrong. Since, Compatibility and Casting problems.
-> Therefore, we cannot assign the address of floating variable rate into the integer pointer variable P.
-> The problem of Compatibility and Casting, can be solved by using Generic Pointer.

The Generic Pointer:

-> The void pointer is a generic pointer that can represent any pointer type.
-> All pointer types can be assigned to a void pointer and a void pointer can be assigned to any pointer without casting. 

Example 4:            void *vp;    (generic pointer)
                               float rate;
                               vp = &rate;

-> A pointer variable 'vp' with type void is called generic pointer.
-> The syntax in Example 4, resolve the problem of Compatibility and Casting and void pointer vp store the address of floating point variable rate.


Q.1. Why we use a generic pointer in C-Programming ?

Friday, 1 July 2022

Complexity of Infinite Loop

Infinite Loop in C                           

"Infinite Loop in C-code means the loop does not terminate."


Example 1.

C-programing in Linux platform:

1. Open a text-editor -> Write C-code -> Press (ctrl+shift+s) -> type filename.c -> Click on save .
2. Open command prompt (a) For compilation: Type gcc filename.c (b) For execution: Type ./a.out

There are mainly four types of infinite loop in C-programming.

(i) By calling the main function into the main().
(ii) By using for-loop.
(iii) By using while-loop.
(iv) By using do-while-loop.   

# include<stdio.h>
void main ()
{
printf ("hello");
main();
}

The output of this C-programming: hellohellohello--------------till interrupt (ctrl+z). 

#include<stdio.h>
int main()
{
for(;;)
{
printf("hello \n");
}
return(0);
}


#include<stdio.h>
int main()
{
while(1)
{
printf("hello\n");
}
return(0);
}

#include<stdio.h>
int main()
{
do
{
printf("hello\n");
}
while(1);
return(0);
}

If the return type of main() function is an integer then we must include a return(0) function in our code.  

On Windows Platforms (Turbo C++):

Example 2.

#include<stdio.h>
#include<conio.h>
void main ()
{
for (;;)
{
printf ("hello");
}
clrscr ();
getch ();
}

In "Turbo c++" compiler, we must include getch() and clrscr() function for displaying the output on clear screen.
 

Wednesday, 29 June 2022

The HTML

The Hyper Text Markup Language (HTML)

General Information:

-> HTML is a formatting language that's used for static web page design.

-> It's not a programming language.

-> There are mainly three types of World Wide Web (WWW) documents or pages.

-> Static web pages, Dynamic web pages and Active web pages.

-> JavaScript, Cascading Style Sheet (CSS) and Hypertext Pre-processor (PHP) also known as Personal Home Page, uses for designing the Dynamic / Active web pages.

-> XML: Extensible Markup Language: It has the same functionality as like HTML, but XML provides flexibility to the developer. It is used to transport data from one application or script to another.   

HTML Tags: 

-> The html tags are categorized into a container tag or an empty tag.  

Container Tags:

Tags comes in pair with an opening tag and closing tag, called container tags.

-> Opening tags indicating the start of the formatting. e.g. <b> = Opening tag for bold the text. 
-> Closing tags indicating the end of the formatting. e.g. </b> = Closing tag for bold the text.

Empty Tags:

In contrast, an empty tag has only an opening tag.
e.g. <br> = Break tag: It is used to break the line or new-line.

Structure of HTML: 

Note: HTML is not case-sensitive. Its tag may be written in upper case or lower case. 

<html> 

        <comment> This section used to identify the page as a web page </comment>

                <head>

                                    <title>
                                    
                                        The optional Section will appear in the title bar of the web browser.

                                     </title>

                </head>

                <body>

                    The actual content of the document.

                </body>

</html>

Open a text editor / notepad -> Write the above tags to your opened text editor -> Save the text editor using (ctrl+s) as filename.html in any folder of your computer -> Go to the folder -> "double click" on "flilename.html".



Monday, 20 June 2022

Types of Computer

Computer Generations:

"Computer Generation" refers to the advancements of technology, speed, storage capacity and the reduction of the prices and the size of the computers.

(i) First Generation: (1946-1955) - Made by using Vacuum tubes, Examples: ("ENIAC" and "UNIVAC").

(ii) Second Generation: (1956-1965) - Made by using Transistor.

(iii) Third Generation: (1966-1975) - Made by using Integrated Circuits (IC) chips.

(iv) Fourth Generation: (1976-2010) - Made by using Very Large Scale Integration (VLSI) Technology.

(v) Fifth Generation: (2010-Present) - Made by using Artificial Intelligence (AI).

Computer Models:

Models: Depending on shape, sizes and capabilities modern computer are mainly four types.

(i) Micro Computers,

(ii) Mini Computers,

(iii) Mainframe Computers,

(iv) Super Computers

Computer Types:

Based on principle of operations, computers are classified into following three types:

(i) Digital Computers,

(ii) Analog Computers,

(iii) Hybrid Computers.

Intelligence Quotient (I.Q.) of the COMPUTER

How to compute the intelligence quotient (I.Q.) of any object or system or animal:



$Intelligence \;Quotient (I.Q.)$ = $\frac{Mental \;Age\; of\; the\; System}{Chronological \;Age \;of\; the\; System}*100$


Since the Mental Age of the non-living System = 0.


$Intelligence\; Quotient (I.Q.)$ = $\frac{0}{Chronological\; Age\; of\; the\; System}*100$



$I.Q. \; of\; the\; Computer \;System$ = $\frac{0}{Chronological\; Age\; of\; the\; System}*100$


Still the I.Q. of the Computer System = 0.


Q. What is the I.Q. of the computer?





IPO Cycle

Introduction to Computer: -  The computer is a modern electronic machine that can receive data or information and can store & process the data as per instructions and finally can display the results accurately is named as Computer.  


In other words, the computer is a modern electronic device that performs basically three operations in a sequence.  

1. It receives data (an instruction).

2. It processes data (as per instruction).

3. It emits data (output). 

This cycle of operations in a computer is known as input-process-output (IPO) cycle.

Q. 1. What do you mean by IPO cycle in the computer.

PRINCIPAL COMPONENT ANALYSIS (PCA)

(PCA) : - Dimension reduction analysis -> It is a technique for feature extraction from a given data set. -> There are N -number...