This is the extraction of the program's main function.If I do this, it should rotate 90 degrees, but I can't.As a countermeasure,
int main(intargc, char*arge[]){
structure img_data img_org, img_out;
/* Image loading*/
img_org = img_from_pgm(arge[1]);
/*Image Processing*/
img_out=ImageProcessing(img_org);
/* Image Export*/
img_to_pgm(img_out, age[2]);
return1;
}
/*Image Processing*/
struct img_data ImageProcessing(struct img_data img_in){
inti,j;
structure img_data img_out;
/* Image preparation for output*/
img_out=img_set(img_in.ysize, img_in.xsize);
/* Processing Department*/
for(j=0;j<img_in.ysize;j++)
for(i=0;i<img_in.xsize;i++){
img_out.data[i][j]=img_in.data[img_in.xsize-j-1][i];/*???*/
}
/* Return Processing Results */
return img_out;
}
Image Processing
for 90 degree left rotationimg_out.data[i][j]=img_in.data[img_in.xsize-j-1][i];
If you change to the following, it will work.
img_out.data[i][j]=img_in.data[j][img_in.xsize-j-1];
I thought it would be easier to focus on INPUT instead of OUTPUT.
img_out.data[img_in.xsize-i-1][j]=img_in.data[j][i];
In my opinion, it would be better to draw pictures and build logic.
Input data
+--+--+--+
| 1| 2| 3|
+--+--+--+
| 4| 5| 6|
+--+--+--+
| 7| 8| 9|
+--+--+--+
|10|11|12|
+--+--+--+
output data
+--+--+--+--+
| 3| 6| 9|12|
+--+--+--+--+
| 2| 5| 8|11|
+--+--+--+--+
| 1| 4| 7|10|
+--+--+--+--+
© 2024 OneMinuteCode. All rights reserved.