translate the pseudo code into C code Labelid 1 Initial La

translate the pseudo code into C code.

Label_id = 1                         // Initial Label number

for each pixel {

if pixel X is SET {

    if neighbors A,B,C & D are unlabelled (equal to zero) {

      label pixel X with Label_id

      increment Label_id

    } else {

       num = scan neighbor labels A,B,C & D with MINIMUM value (not zero)

       label pixel X and pixels A, B, C & D if SET with num

    }

}

}

Solution

**********************************C code*************************************************

#include<stdio.h>
#include<conio.h>

int main(){
  
int label_id=1; //label declared and initialized with value 1
int a, b, c, d;
int pixel, x, num;
  
printf(\"Enter the value of neighbors A:\"); //-------line 1
scanf(\"%d\",&a);
printf(\"Enter the value of neighbors B:\"); //-------line 2
scanf(\"%d\",&b);
printf(\"Enter the value of neighbors C:\"); //-------line 3
scanf(\"%d\",&c);
printf(\"Enter the value of neighbors D:\");
scanf(\"%d\",&d); //-------line 4
printf(\"Enter the value of pixel x:\");
scanf(\"%d\",&x);
  
for(pixel=0;pixel<=x;pixel++){
  
if(x){
  
if(a==0 && b==0 && c==0 && d==0){
  
x=label_id;
//printf(\"%d\",x); //for print value of pixel x
label_id++;
  
}
}else{
// a=1;
// b=2;
//c=3;
// d=4;
num=a+b+c+d; //if you want to again insert a,b,c,d value then put code line 1 to line 4 code here
if(num){
  
//printf(\"%d\",x); //for print value of pixel x
//printf(\"%d\",a,b,c,d); //for print value of neighbors
  
}
  
//printf(\"%d\",x); //for print value of pixel x
  
}
  
}
  

}

translate the pseudo code into C code. Label_id = 1 // Initial Label number for each pixel { if pixel X is SET { if neighbors A,B,C & D are unlabelled (equa
translate the pseudo code into C code. Label_id = 1 // Initial Label number for each pixel { if pixel X is SET { if neighbors A,B,C & D are unlabelled (equa

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site