added a rotate image function in lab1

This commit is contained in:
ItsMAX0112 2024-09-12 15:13:25 +05:30
parent aee8de18b2
commit 485d24557f
12 changed files with 59 additions and 1 deletions

6
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,6 @@
{
"files.associations": {
"ostream": "cpp",
"chrono": "cpp"
}
}

BIN
lab1/images/1rotated.ppm Normal file

Binary file not shown.

BIN
lab1/images/2rotated.ppm Normal file

Binary file not shown.

Binary file not shown.

View File

@ -33,3 +33,5 @@
../images/5.ppm 0.352959 ../images/5.ppm 0.352959
../images/6.ppm 0.497504 ../images/6.ppm 0.497504
../images/7.ppm 1.79435 ../images/7.ppm 1.79435
../images/1.ppm 0.00378666
../images/2.ppm 0.0142673

View File

@ -103,6 +103,38 @@ struct image_t* S2_find_details(struct image_t *input_image, struct image_t *smo
return details; 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) struct image_t* S3_sharpen(struct image_t *input_image, struct image_t *details_image)
{ {
// TODO // TODO
@ -159,9 +191,11 @@ int main(int argc, char **argv)
auto startsharp = chrono::high_resolution_clock::now(); auto startsharp = chrono::high_resolution_clock::now();
struct image_t *sharpened_image = S3_sharpen(input_image, details_image); struct image_t *sharpened_image = S3_sharpen(input_image, details_image);
auto endsharp = std::chrono::high_resolution_clock::now(); auto endsharp = std::chrono::high_resolution_clock::now();
struct image_t *rotated_image = Rotate_image(input_image);
auto startwrite = chrono::high_resolution_clock::now(); 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(); auto endwrite = std::chrono::high_resolution_clock::now();
chrono::duration<double> readduration = endread - startread; chrono::duration<double> readduration = endread - startread;

View File

@ -33,3 +33,5 @@
../images/5.ppm 0.366631 ../images/5.ppm 0.366631
../images/6.ppm 0.711473 ../images/6.ppm 0.711473
../images/7.ppm 1.80572 ../images/7.ppm 1.80572
../images/1.ppm 0.0197896
../images/2.ppm 0.0329337

View File

@ -33,3 +33,5 @@
../images/5.ppm 0.396153 ../images/5.ppm 0.396153
../images/6.ppm 0.804332 ../images/6.ppm 0.804332
../images/7.ppm 2.54863 ../images/7.ppm 2.54863
../images/1.ppm 0.00357817
../images/2.ppm 0.0139955

View File

@ -33,3 +33,5 @@
../images/5.ppm 0.448171 ../images/5.ppm 0.448171
../images/6.ppm 1.03631 ../images/6.ppm 1.03631
../images/7.ppm 2.50061 ../images/7.ppm 2.50061
../images/1.ppm 0.00590421
../images/2.ppm 0.0222273

View File

@ -33,3 +33,5 @@
../images/5.ppm 0.127681 ../images/5.ppm 0.127681
../images/6.ppm 0.322058 ../images/6.ppm 0.322058
../images/7.ppm 1.0496 ../images/7.ppm 1.0496
../images/1.ppm 0.00731258
../images/2.ppm 0.02392

Binary file not shown.

8
lab3/schedule_format.txt Normal file
View File

@ -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