📄 pattern.c
字号:
out_image[i][j] = 0;
for(i=50; i<80; i++)
for(j=50; j<80; j++)
out_image[i][j] = 2;
for(i=30; i<60; i++)
for(j=30; j<60; j++)
out_image[i][j] = 5;
/* depth file with four levels */
for(i=0; i<rows; i++)
for(j=0; j<cols; j++)
out_image[i][j] = 0;
for(i=20; i<80; i++)
for(j=20; j<80; j++)
out_image[i][j] = 2;
for(i=30; i<70; i++)
for(j=30; j<70; j++)
out_image[i][j] = 3;
for(i=40; i<60; i++)
for(j=40; j<60; j++)
out_image[i][j] = 4;
/* basic two square for a depth file */
for(i=0; i<rows; i++)
for(j=0; j<cols; j++)
out_image[i][j] = 0;
for(i=30; i<60; i++)
for(j=30; j<60; j++)
out_image[i][j] = 2;
for(i=50; i<80; i++)
for(j=50; j<80; j++)
out_image[i][j] = 4;
/* depth file with four levels */
for(i=0; i<rows; i++)
for(j=0; j<cols; j++)
out_image[i][j] = 0;
for(i=20; i<80; i++)
for(j=20; j<80; j++)
out_image[i][j] = 2;
for(i=35; i<65; i++)
for(j=35; j<65; j++)
out_image[i][j] = 4;
for(i=45; i<45; i++)
for(j=45; j<45; j++)
out_image[i][j] = 6;
/* depth file with two levels */
for(i=0; i<rows; i++)
for(j=0; j<cols; j++)
out_image[i][j] = 0;
for(i=20; i<60; i++)
for(j=20; j<60; j++)
out_image[i][j] = 2;
for(i=40; i<80; i++)
for(j=40; j<80; j++)
out_image[i][j] = 5;
/* basic square for a depth file */
for(i=0; i<rows; i++)
for(j=0; j<cols; j++)
out_image[i][j] = 0;
for(i=30; i<70; i++)
for(j=30; j<70; j++)
out_image[i][j] = 5;
/* make a step pattern of gray shades */
for(i=0; i<rows; i++)
for(j=0; j<cols; j++)
out_image[i][j] = 0;
for(i=0; i<rows; i++)
for(j=10; j<20; j++)
out_image[i][j] = 5;
for(i=0; i<rows; i++)
for(j=20; j<30; j++)
out_image[i][j] = 10;
for(i=0; i<rows; i++)
for(j=30; j<40; j++)
out_image[i][j] = 20;
/* make a club to look at thinning and mat */
for(i=0; i<rows; i++){
for(j=0; j<cols; j++){
if( i>4 && i<11 && j>4 && j<17)
out_image[i][j] = 200;
else
out_image[i][j] = 0;
}
}
for(i=0; i<rows; i++){
for(j=0; j<cols; j++){
if( i>1 && i<17 && j>4 && j<11)
out_image[i][j] = 200;
}
}
/* make a rectangle with a hole in it */
for(i=0; i<rows; i++){
for(j=0; j<cols; j++){
if( i>=5 && i<=8 && j>=5 && j<=18)
out_image[i][j] = 200;
}
}
for(i=0; i<rows; i++){
for(j=0; j<cols; j++){
if( i>=15 && i<=18 && j>=5 && j<=18)
out_image[i][j] = 200;
}
}
for(i=0; i<rows; i++){
for(j=0; j<cols; j++){
if( j>=5 && j<=8 && i>=5 && i<=18)
out_image[i][j] = 200;
}
}
for(i=0; i<rows; i++){
for(j=0; j<cols; j++){
if( j>=15 && j<=18 && i>=5 && i<=18)
out_image[i][j] = 200;
}
}
/* make the entire area white with a black hole
in it good for interior outline */
for(i=0; i<rows; i++){
for(j=0; j<cols; j++){
if( i>=10 && i<=15 && j>=10 && j<=18)
out_image[i][j] = 0;
else
out_image[i][j] = 200;
}
}
/* make a square */
for(i=0; i<rows; i++){
for(j=0; j<cols; j++){
if( i>=8 && i<=18 && j>=8 && j<=18)
out_image[i][j] = 200;
else
out_image[i][j] = 0;
}
}
/* make a square with a hole in
it for closing practice */
for(i=0; i<rows; i++){
for(j=0; j<cols; j++){
if( i>=8 && i<=13 && j>=8 && j<=13)
out_image[i][j] = 200;
else
out_image[i][j] = 0;
}
}
out_image[10][10] = 0;
out_image[11][10] = 0;
/* make 2 small squares
illustrate closing and special closing */
for(i=0; i<rows; i++)
for(j=0; j<cols; j++)
out_image[i][j] = 0;
for(i=0; i<rows; i++){
for(j=0; j<cols; j++){
if( i>=8 && i<=13 && j>=8 && j<=9)
out_image[i][j] = 200;
if( i>=8 && i<=13 && j>=11 && j<=13)
out_image[i][j] = 200;
}
}
/* make a rectangle */
for(i=0; i<rows; i++){
for(j=0; j<cols; j++){
if( i>=8 && i<=18 && j>=4 && j<=18)
out_image[i][j] = 200;
else
out_image[i][j] = 0;
}
}
/* make a block letter A */
for(i=0; i<rows; i++)
for(j=0; j<cols; j++)
out_image[i][j] = 0;
for(i=0; i<rows; i++)
for(j=0; j<cols; j++)
if(i>=10 && i<=20 && j>=10 && j<=50)
out_image[i][j] = 200;
for(i=0; i<rows; i++)
for(j=0; j<cols; j++)
if(i>=40 && i<=50 && j>=10 && j<=50)
out_image[i][j] = 200;
for(i=0; i<rows; i++)
for(j=0; j<cols; j++)
if(i>=10 && i<=90 && j>=10 && j<=20)
out_image[i][j] = 200;
for(i=0; i<rows; i++)
for(j=0; j<cols; j++)
if(i>=10 && i<=90 && j>=40 && j<=50)
out_image[i][j] = 200;
/* make a broken line */
for(i=0; i<rows; i++)
for(j=0; j<cols; j++)
out_image[i][j] = 0;
for(i=0; i<rows; i++)
for(j=0; j<cols; j++)
if(i>=10 && i<=11 && j>=5 && j<=18)
out_image[i][j] = 200;
out_image[10][11] = 0;
out_image[11][11] = 0;
/* make two squares joined together */
for(i=0; i<rows; i++)
for(j=0; j<cols; j++)
out_image[i][j] = 0;
for(i=0; i<rows; i++){
for(j=0; j<cols; j++){
if( i>=5 && i<=15 && j>=5 && j<=9)
out_image[i][j] = 200;
if( i>=5 && i<=15 && j>=12 && j<=17)
out_image[i][j] = 200;
}
}
out_image[10][10] = 200;
out_image[10][11] = 200;
/* make a texture, checkerboard of 100-200
with each square the size given by the
variable square_size
I'll do this a little different and let
the user specify the square size as the
last parameter on the line. */
sqaure_size = atoi(argv[4]);
ii=0;
jj=0;
set_i=0;
set_j=0;
for(i=0; i<rows; i++){
for(j=0; j<cols; j++){
/* odd rows */
if( (set_i%2) == 0){
if( (set_j%2) == 0)
out_image[i][j] = 100;
else
out_image[i][j] = 200;
}
/* even rows */
else{
if( (set_j%2) == 0)
out_image[i][j] = 200;
else
out_image[i][j] = 100;
}
jj++;
if(jj > square_size){
jj = 0;
set_j++;
}
} /* ends loop over j */
jj=0;
set_j=0;
ii++;
if(ii > square_size){
ii = 0;
set_i++;
}
} /* ends loop over i */
/* create a random image 0-255 */
for(i=0; i<rows; i++)
for(j=0; j<cols; j++)
out_image[i][j] = (rand() % 255);
/* create a random image 100-150 */
for(i=0; i<rows; i++)
for(j=0; j<cols; j++)
out_image[i][j] = 100 + (rand() % 50);
/* make vertical stripes */
for(i=0; i<rows; i++){
for(j=0; j<cols; j++){
if( (j > 10 && j < 30) ||
(j > 50 && j < 70) ||
(j > 90 && j < 99) )
out_image[i][j] = 200;
else
out_image[i][j] = 50;
}
}
/* make a blank image that is not zero */
for(i=0; i<rows; i++){
for(j=0; j<cols; j++){
out_image[i][j] = 150;
}
}
/* make a random pattern background */
for(i=0; i<rows/2; i++)
for(j=0; j<cols/2; j++)
out_image[i][j] = (abs(rand()) ) % 255;
/* make a horizontal stripe */
for(i=10; i<20; i++)
for(j=0; j<cols/2; j++)
out_image[i][j] = (abs(rand()) ) % 25 + 50;
/* make a horizontal stripe */
for(i=30; i<40; i++)
for(j=0; j<cols/2; j++)
out_image[i][j] = (abs(rand()) ) % 25 + 50;
/* make a vertical stripe */
for(i=0; i<rows/2; i++)
for(j=10; j<20; j++)
out_image[i][j] = (abs(rand()) ) % 25 + 50;
/* make a vertical stripe */
for(i=0; i<rows/2; i++)
for(j=30; j<40; j++)
out_image[i][j] = (abs(rand()) ) % 25 + 50;
/* copy the 50x50 to the rest of the 100x100 */
for(i=0; i<50; i++)
for(j=50; j<cols; j++)
out_image[i][j] = out_image[i][j-50];
for(i=50; i<rows; i++)
for(j=0; j<50; j++)
out_image[i][j] = out_image[i-50][j];
for(i=50; i<rows; i++)
for(j=50; j<cols; j++)
out_image[i][j] = out_image[i-50][j-50];
/* make the left edge look like the right edge */
for(i=0; i<rows; i++)
for(j=90; j<cols; j++)
out_image[i][j] = out_image[i][j-90];
/* make the bottom edge look like the top edge */
for(i=90; i<rows; i++)
for(j=0; j<cols; j++)
out_image[i][j] = out_image[i-90][j];
short p1[10][10] =
{{11, 11, 11, 11, 11, 11, 11, 11, 11, 11},
{11, 11, 11, 11, 11, 11, 11, 11, 11, 11},
{11, 11, 11, 11, 11, 11, 11, 11, 11, 11},
{11, 11, 11, 11, 11, 11, 11, 11, 11, 11},
{11, 11, 11, 11, 11, 11, 11, 11, 11, 11},
{11, 11, 11, 11, 11, 11, 11, 11, 11, 11},
{11, 11, 11, 11, 11, 11, 11, 11, 11, 11},
{11, 11, 11, 11, 11, 11, 11, 11, 11, 11},
{11, 11, 11, 11, 11, 11, 11, 11, 11, 11},
{11, 11, 11, 11, 11, 11, 11, 11, 11, 11}};
short p2[10][10] =
{{11, 11, 11, 11, 11, 11, 11, 11, 11, 11},
{11, 11, 11, 11, 11, 11, 11, 11, 11, 11},
{11, 11, 11, 11, 11, 11, 11, 11, 11, 11},
{11, 11, 11, 11, 11, 11, 11, 11, 11, 11},
{11, 11, 11, 11, 11, 11, 11, 11, 11, 11},
{11, 11, 11, 11, 11, 11, 11, 11, 11, 11},
{11, 11, 11, 11, 11, 11, 11, 11, 11, 11},
{11, 11, 11, 11, 11, 11, 11, 11, 11, 11},
{11, 11, 11, 11, 11, 11, 11, 11, 11, 11},
{11, 11, 11, 11, 11, 11, 11, 11, 11, 11}};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -