added a rotate image function in lab1
This commit is contained in:
parent
aee8de18b2
commit
485d24557f
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"files.associations": {
|
||||
"ostream": "cpp",
|
||||
"chrono": "cpp"
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
BIN
lab1/src/a.out
BIN
lab1/src/a.out
Binary file not shown.
|
@ -33,3 +33,5 @@
|
|||
../images/5.ppm 0.352959
|
||||
../images/6.ppm 0.497504
|
||||
../images/7.ppm 1.79435
|
||||
../images/1.ppm 0.00378666
|
||||
../images/2.ppm 0.0142673
|
||||
|
|
|
@ -103,6 +103,38 @@ struct image_t* S2_find_details(struct image_t *input_image, struct image_t *smo
|
|||
return details;
|
||||
}
|
||||
|
||||
struct image_t* Rotate_image(struct image_t *input_image)
|
||||
{
|
||||
// TODO
|
||||
int width = input_image->width;
|
||||
int height = input_image->height;
|
||||
|
||||
struct image_t* rotated = new struct image_t;
|
||||
rotated->height = width;
|
||||
rotated->width = height;
|
||||
rotated->image_pixels = new uint8_t**[height];
|
||||
|
||||
for(int i = 0; i < rotated->height; i++)
|
||||
{
|
||||
rotated->image_pixels[i] = new uint8_t*[rotated->width];
|
||||
for(int j = 0; j < rotated->width; j++)
|
||||
rotated->image_pixels[i][j] = new uint8_t[3];
|
||||
}
|
||||
|
||||
for(int i = 1; i < rotated->height-1; i++)
|
||||
{
|
||||
for(int j = 1; j < rotated->width-1; j++)
|
||||
{
|
||||
for(int k = 0; k < 3; k++)
|
||||
{
|
||||
rotated->image_pixels[i][j][k] = input_image->image_pixels[j][i][k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rotated;
|
||||
}
|
||||
|
||||
struct image_t* S3_sharpen(struct image_t *input_image, struct image_t *details_image)
|
||||
{
|
||||
// TODO
|
||||
|
@ -160,8 +192,10 @@ int main(int argc, char **argv)
|
|||
struct image_t *sharpened_image = S3_sharpen(input_image, details_image);
|
||||
auto endsharp = std::chrono::high_resolution_clock::now();
|
||||
|
||||
struct image_t *rotated_image = Rotate_image(input_image);
|
||||
|
||||
auto startwrite = chrono::high_resolution_clock::now();
|
||||
write_ppm_file(argv[2], sharpened_image);
|
||||
write_ppm_file(argv[2], rotated_image);
|
||||
auto endwrite = std::chrono::high_resolution_clock::now();
|
||||
|
||||
chrono::duration<double> readduration = endread - startread;
|
||||
|
|
|
@ -33,3 +33,5 @@
|
|||
../images/5.ppm 0.366631
|
||||
../images/6.ppm 0.711473
|
||||
../images/7.ppm 1.80572
|
||||
../images/1.ppm 0.0197896
|
||||
../images/2.ppm 0.0329337
|
||||
|
|
|
@ -33,3 +33,5 @@
|
|||
../images/5.ppm 0.396153
|
||||
../images/6.ppm 0.804332
|
||||
../images/7.ppm 2.54863
|
||||
../images/1.ppm 0.00357817
|
||||
../images/2.ppm 0.0139955
|
||||
|
|
|
@ -33,3 +33,5 @@
|
|||
../images/5.ppm 0.448171
|
||||
../images/6.ppm 1.03631
|
||||
../images/7.ppm 2.50061
|
||||
../images/1.ppm 0.00590421
|
||||
../images/2.ppm 0.0222273
|
||||
|
|
|
@ -33,3 +33,5 @@
|
|||
../images/5.ppm 0.127681
|
||||
../images/6.ppm 0.322058
|
||||
../images/7.ppm 1.0496
|
||||
../images/1.ppm 0.00731258
|
||||
../images/2.ppm 0.02392
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,8 @@
|
|||
CPU0
|
||||
P1,1 0 0
|
||||
P2,1 1 3
|
||||
P1,1 4 7
|
||||
P2,1 8 10
|
||||
P3,1 11 12
|
||||
P2,1 13 15
|
||||
|
Loading…
Reference in New Issue