분명 내 계산에는 12주차인데.... 왜 11주 차라고 하는지는 미지수;;;
파일 입출력입니다. 256*256의 raw파일을 제어 하는것입니다.
돌리고 막 잉 거울효과에 인버팅에 막 여러가지 작업을 하는겁니다.
Code Type : C
#include< stdio.h>
#include< stdlib.h>
void main()
{
FILE *read_fp, *write_fp;
int i,j;
unsigned char temp[256][256];
unsigned char write[256][256];
unsigned char write_temp[256][256];
read_fp=fopen("Lena(256x256).raw","rb");
if(!read_fp)
printf("파일이 존재하지 않습니다.\n"),exit(1);
fread(temp,sizeof(unsigned char),256*256,read_fp);
fclose(read_fp);
// 회전부 Rotate Right
for(i=0;i<=255;i++)
for(j=0;j<=255;j++)
write[j][255-i] = temp[i][j];
write_fp = fopen("rotate_right.raw","wb");
fwrite(write,sizeof(unsigned char),256*256,write_fp);
puts("우로 회전 완료");
fclose(write_fp);
// 회전부 Rotate Left
for(i=0;i<=255;i++)
for(j=0;j<=255;j++)
write[255-j][i] = temp[i][j];
write_fp = fopen("rotate_left.raw","wb");
fwrite(write,sizeof(unsigned char),256*256,write_fp);
puts("좌로 회전 완료");
fclose(write_fp);
// 인버팅부
for(i=0;i<=255;i++)
for(j=0;j<=255;j++)
write[i][j]=~temp[i][j];
//write[i][j]=255 - temp[i][j];
write_fp = fopen("invert.raw","wb");
fwrite(write,sizeof(unsigned char),256*256,write_fp);
puts("역상 효과 완료");
fclose(write_fp);
// 거울 효과
for(i=0;i<=255;i++)
for(j=0;j<=255;j++)
write[i][255-j] = temp[i][j];
write_fp = fopen("mirror.raw","wb");
fwrite(write,sizeof(unsigned char),256*256,write_fp);
puts("거울 효과 완료");
fclose(write_fp);
// Vertical
for(i=0;i<=255;i++)
for(j=0;j<=255;j++)
write[255-i][j] = temp[i][j];
write_fp = fopen("vertical.raw","wb");
fwrite(write,sizeof(unsigned char),256*256,write_fp);
puts("상하 반전 완료");
fclose(write_fp);
// Rotation & Inverting
for(i=0;i<=255;i++)
for(j=0;j<=255;j++)
write_temp[255-j][i] = temp[i][j];
for(i=0;i<=255;i++)
for(j=0;j<=255;j++)
write[i][j]=255 - write_temp[i][j];
write_fp = fopen("rotation_inverting.raw","wb");
fwrite(write,sizeof(unsigned char),256*256,write_fp);
puts("회전후 역상 완료");
fclose(write_fp);
}