cleaning lab4 dir

This commit is contained in:
ItsMAX0112 2024-10-15 17:05:25 +05:30
parent e8d5f8a918
commit 804288ddac
10 changed files with 170 additions and 420 deletions

View File

@ -48,11 +48,28 @@ int main(int argc, char *argv[]) {
CHILD = fork();
if (CHILD == -1) {
perror("fork");
perror("fork failed!");
exit(EXIT_FAILURE);
}
if (CHILD == 0) { /* Child reads from pipe */
// Parent Process
if(CHILD != 0){
close(pipe1[0]); /* Close unused read end of pipe 1 */
close(pipe2[0]); /* Close unused read end of pipe 2*/
close(pipe2[1]); /* Close unused write end of pipe 2*/
struct image_t *input_image = read_ppm_file(argv[1]);
struct image_t *smoothened_image = S1_smoothen(input_image);
printf("parent writing to pipe\n");
write(pipe1[1], argv[1], strlen(argv[1])); /* Parent writes argv[1] to pipe */
close(pipe1[1]); /* Reader will see EOF */
wait(NULL); /* Wait for child */
}
// Child process
else if (CHILD == 0) { /* Child reads from pipe */
if (pipe(pipe2) == -1) {
perror("pipe2");
@ -62,26 +79,12 @@ int main(int argc, char *argv[]) {
pid_t GRAND_CHILD = fork();
if (GRAND_CHILD == -1) {
perror("fork");
perror("fork failed!");
exit(EXIT_FAILURE);
}
if (GRAND_CHILD == 0) { /* Child reads from pipe */
close(pipe1[1]); /* Close unused write end for s1_s2 pipe */
close(pipe1[0]); /* Close unused read end for s1_s2 pipe */
close(pipe2[1]); /* Close unused write end for s2_s3 pipe */
char to_print[] = "C : x\n";
char buf1;
while (read(pipe2[0], &buf1, 1) > 0)
{
cout << "in child ka child" << endl;
to_print[4] = buf;
}
close(pipe2[0]);
exit(EXIT_SUCCESS);
}
else {
// Child Process
if(GRAND_CHILD != 0){
close(pipe1[1]); /* Close unused write end for s1_s2 pipe */
close(pipe2[0]); /* Close unused read end for s2_s3 pipe */
char to_print[] = "C : x\n";
@ -100,17 +103,24 @@ int main(int argc, char *argv[]) {
exit(EXIT_SUCCESS);
}
}
else { /* Parent writes argv[1] to pipe */
close(pipe1[0]); /* Close unused read end of pipe 1 */
close(pipe2[0]); /* Close unused read end of pipe 2*/
close(pipe2[1]); /* Close unused write end of pipe 2*/
printf("parent writing to pipe\n");
write(pipe1[1], argv[1], strlen(argv[1]));
close(pipe1[1]); /* Reader will see EOF */
wait(NULL); /* Wait for child */
}
// GrandChild Process
else if (GRAND_CHILD == 0) { /* Child reads from pipe */
close(pipe1[1]); /* Close unused write end for s1_s2 pipe */
close(pipe1[0]); /* Close unused read end for s1_s2 pipe */
close(pipe2[1]); /* Close unused write end for s2_s3 pipe */
char to_print[] = "C : x\n";
char buf1;
while (read(pipe2[0], &buf1, 1) > 0)
{
cout << "in child ka child" << endl;
to_print[4] = buf;
}
close(pipe2[0]);
exit(EXIT_SUCCESS);
}
}
cout << "success" << endl;
return 0;

View File

@ -1,38 +0,0 @@
../images/1.ppm 0.0240894
../images/2.ppm 0.0798028
../images/3.ppm 0.136535
../images/4.ppm 0.248314
../images/5.ppm 0.363927
../images/6.ppm 0.814739
../images/7.ppm 3.20648
../images/1.ppm 0.0255179
../images/2.ppm 0.082453
../images/3.ppm 0.187293
../images/4.ppm 0.504723
../images/5.ppm 0.421034
../images/6.ppm 0.905171
../images/7.ppm 4.12279
../images/1.ppm 0.0105311
../images/2.ppm 0.0422888
../images/3.ppm 0.0912897
../images/4.ppm 0.204927
../images/5.ppm 0.497162
../images/6.ppm 0.452158
../images/7.ppm 1.66216
../images/1.ppm 0.0135349
../images/2.ppm 0.0437362
../images/3.ppm 0.0821199
../images/4.ppm 0.54249
../images/5.ppm 0.39126
../images/6.ppm 0.555806
../images/7.ppm 2.16977
../images/1.ppm 0.0217065
../images/2.ppm 0.0748607
../images/3.ppm 0.174253
../images/4.ppm 0.201994
../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
../images/3.ppm 0.0612914

View File

@ -1,26 +0,0 @@
import matplotlib.pyplot as plt
pixels = [81000, 308898, 588800, 1164800, 1500000, 3406500, 9262500]
read_time = [0.0372315, 0.1104362, 0.162849, 0.3120326, 0.4681494, 0.9840036, 1.665642]
smoothened_time = [0.03347448, 0.1221104, 0.2514082, 0.4795412, 0.6044902, 1.1334092, 2.453936]
details_time = [0.01907596, 0.0646283, 0.13429812, 0.3404896, 0.4052684, 0.6450756, 2.591112]
sharpened_time = [0.02013736, 0.07459558, 0.13045596, 0.2987406, 0.4569202, 0.699245, 3.019178]
write_time = [0.010278664, 0.03954574, 0.05814792, 0.1842653, 0.2484992, 0.304828, 1.119439]
plt.figure(figsize=(12, 8))
plt.plot(pixels, read_time, marker='o', label='Read Time')
plt.plot(pixels, smoothened_time, marker='o', label='Smoothened Time')
plt.plot(pixels, details_time, marker='o', label='Details Time')
plt.plot(pixels, sharpened_time, marker='o', label='Sharpened Time')
plt.plot(pixels, write_time, marker='o', label='Write Time')
plt.xlabel('Pixels')
plt.ylabel('Time (seconds)')
plt.title('Pixels vs Time')
plt.legend()
plt.grid(True)
plt.xscale('log')
plt.yscale('log')
plt.show()

View File

@ -6,63 +6,70 @@
using namespace std;
struct image_t* S1_smoothen(struct image_t *input_image)
struct image_t *S1_smoothen(struct image_t *input_image)
{
//cout << input_image->width << input_image->height << " " << input_image->image_pixels << endl;
// cout << input_image->width << input_image->height << " " << input_image->image_pixels << endl;
int width = input_image->width;
int height = input_image->height;
// memory allocation
struct image_t* smoother = new struct image_t;
struct image_t *smoother = new struct image_t;
smoother->height = height;
smoother->width = width;
smoother->image_pixels = new uint8_t**[height];
for(int i = 0; i < height; i++)
smoother->image_pixels = new uint8_t **[height];
for (int i = 0; i < height; i++)
{
smoother->image_pixels[i] = new uint8_t*[width];
for(int j = 0; j < width; j++)
smoother->image_pixels[i] = new uint8_t *[width];
for (int j = 0; j < width; j++)
smoother->image_pixels[i][j] = new uint8_t[3];
}
for(int i = 1; i < height-1; i++)
for (int i = 1; i < height - 1; i++)
{
for(int j = 1; j < width-1; j++)
for (int j = 1; j < width - 1; j++)
{
for(int k = 0; k < 3; k++)
for (int k = 0; k < 3; k++)
{
//image->image_pixels[i][j][k] = val;
// image->image_pixels[i][j][k] = val;
// edge cases
if(i == 0 && j == 0) { // i-1 and j - 1 doesnt exist
smoother->image_pixels[i][j][k] = ( input_image->image_pixels[i][j][k] / 9+ input_image->image_pixels[i][j+1][k] / 9 + input_image->image_pixels[i+1][j][k] / 9 + input_image->image_pixels[i+1][j+1][k] / 9);
if (i == 0 && j == 0)
{ // i-1 and j - 1 doesnt exist
smoother->image_pixels[i][j][k] = (input_image->image_pixels[i][j][k] / 4 + input_image->image_pixels[i][j + 1][k] / 4 + input_image->image_pixels[i + 1][j][k] / 4 + input_image->image_pixels[i + 1][j + 1][k] / 4);
}
else if(i == height - 1 && j == 0) { // i+1 and j-1 does not exist
smoother->image_pixels[i][j][k] = ( input_image->image_pixels[i-1][j][k] / 9 + input_image->image_pixels[i-1][j+1][k] / 9+ input_image->image_pixels[i][j][k] / 9+ input_image->image_pixels[i][j+1][k] / 9);
else if (i == height - 1 && j == 0)
{ // i+1 and j-1 does not exist
smoother->image_pixels[i][j][k] = (input_image->image_pixels[i - 1][j][k] / 4 + input_image->image_pixels[i - 1][j + 1][k] / 4 + input_image->image_pixels[i][j][k] / 4 + input_image->image_pixels[i][j + 1][k] / 4);
}
else if(i == 0 && j == width - 1) { // i-1 and j+1 does not exist
smoother->image_pixels[i][j][k] = ( input_image->image_pixels[i][j-1][k] / 9 + input_image->image_pixels[i][j][k] / 9+ input_image->image_pixels[i+1][j-1][k] / 9 + input_image->image_pixels[i+1][j][k] / 9);
else if (i == 0 && j == width - 1)
{ // i-1 and j+1 does not exist
smoother->image_pixels[i][j][k] = (input_image->image_pixels[i][j - 1][k] / 4 + input_image->image_pixels[i][j][k] / 4 + input_image->image_pixels[i + 1][j - 1][k] / 4 + input_image->image_pixels[i + 1][j][k] / 4);
}
else if(i == height - 1 && j == width - 1) { // i+1 and j+1 does not exist
smoother->image_pixels[i][j][k] = ( input_image->image_pixels[i-1][j-1][k] / 9 + input_image->image_pixels[i-1][j][k] / 9 + input_image->image_pixels[i][j-1][k] / 9 + input_image->image_pixels[i][j][k] / 9);
else if (i == height - 1 && j == width - 1)
{ // i+1 and j+1 does not exist
smoother->image_pixels[i][j][k] = (input_image->image_pixels[i - 1][j - 1][k] / 4 + input_image->image_pixels[i - 1][j][k] / 4 + input_image->image_pixels[i][j - 1][k] / 4 + input_image->image_pixels[i][j][k] / 4);
}
else if (i == 0) { // i - 1 does not exist
smoother->image_pixels[i][j][k] = ( input_image->image_pixels[i][j-1][k] / 9 + input_image->image_pixels[i][j][k] / 9+ input_image->image_pixels[i][j+1][k] / 9+ input_image->image_pixels[i+1][j-1][k] / 9+ input_image->image_pixels[i+1][j][k] / 9+ input_image->image_pixels[i+1][j+1][k] / 9);
else if (i == 0)
{ // i - 1 does not exist
smoother->image_pixels[i][j][k] = (input_image->image_pixels[i][j - 1][k] / 6 + input_image->image_pixels[i][j][k] / 6 + input_image->image_pixels[i][j + 1][k] / 6 + input_image->image_pixels[i + 1][j - 1][k] / 6 + input_image->image_pixels[i + 1][j][k] / 6 + input_image->image_pixels[i + 1][j + 1][k] / 6);
}
else if(j == 0) { // j -1 does not exist
smoother->image_pixels[i][j][k] = ( input_image->image_pixels[i-1][j][k] / 9+ input_image->image_pixels[i-1][j+1][k] / 9+ input_image->image_pixels[i][j][k] / 9+ input_image->image_pixels[i][j+1][k] / 9+ input_image->image_pixels[i+1][j][k] / 9+ input_image->image_pixels[i+1][j+1][k]/ 9);
else if (j == 0)
{ // j -1 does not exist
smoother->image_pixels[i][j][k] = (input_image->image_pixels[i - 1][j][k] / 6 + input_image->image_pixels[i - 1][j + 1][k] / 6 + input_image->image_pixels[i][j][k] / 6 + input_image->image_pixels[i][j + 1][k] / 6 + input_image->image_pixels[i + 1][j][k] / 6 + input_image->image_pixels[i + 1][j + 1][k] / 6);
}
else if(i == height - 1) { // i+1 does not exist
smoother->image_pixels[i][j][k] = ( input_image->image_pixels[i-1][j-1][k] / 9+ input_image->image_pixels[i-1][j][k] / 9+ input_image->image_pixels[i-1][j+1][k] / 9+ input_image->image_pixels[i][j-1][k] / 9+ input_image->image_pixels[i][j][k] / 9+ input_image->image_pixels[i][j+1][k]/ 9);
else if (i == height - 1)
{ // i+1 does not exist
smoother->image_pixels[i][j][k] = (input_image->image_pixels[i - 1][j - 1][k] / 6 + input_image->image_pixels[i - 1][j][k] / 6 + input_image->image_pixels[i - 1][j + 1][k] / 6 + input_image->image_pixels[i][j - 1][k] / 6 + input_image->image_pixels[i][j][k] / 6 + input_image->image_pixels[i][j + 1][k] / 6);
}
else if(j == width - 1) { // j + 1 does not exist
smoother->image_pixels[i][j][k] = ( input_image->image_pixels[i-1][j-1][k] / 9+ input_image->image_pixels[i-1][j][k] / 9+ input_image->image_pixels[i][j-1][k] / 9+ input_image->image_pixels[i][j][k]/ 9 + input_image->image_pixels[i+1][j-1][k] / 9+ input_image->image_pixels[i+1][j][k] / 9);
else if (j == width - 1)
{ // j + 1 does not exist
smoother->image_pixels[i][j][k] = (input_image->image_pixels[i - 1][j - 1][k] / 6 + input_image->image_pixels[i - 1][j][k] / 6 + input_image->image_pixels[i][j - 1][k] / 6 + input_image->image_pixels[i][j][k] / 6 + input_image->image_pixels[i + 1][j - 1][k] / 6 + input_image->image_pixels[i + 1][j][k] / 6);
}
else {
smoother->image_pixels[i][j][k] = ( input_image->image_pixels[i-1][j-1][k] / 9 + input_image->image_pixels[i-1][j][k] / 9 + input_image->image_pixels[i-1][j+1][k]/9 + input_image->image_pixels[i][j-1][k]/9 + input_image->image_pixels[i][j][k] / 9 + input_image->image_pixels[i][j+1][k] / 9 + input_image->image_pixels[i+1][j-1][k] / 9 + input_image->image_pixels[i+1][j][k] / 9 + input_image->image_pixels[i+1][j+1][k] / 9);
else
{
smoother->image_pixels[i][j][k] = (input_image->image_pixels[i - 1][j - 1][k] / 9 + input_image->image_pixels[i - 1][j][k] / 9 + input_image->image_pixels[i - 1][j + 1][k] / 9 + input_image->image_pixels[i][j - 1][k] / 9 + input_image->image_pixels[i][j][k] / 9 + input_image->image_pixels[i][j + 1][k] / 9 + input_image->image_pixels[i + 1][j - 1][k] / 9 + input_image->image_pixels[i + 1][j][k] / 9 + input_image->image_pixels[i + 1][j + 1][k] / 9);
}
}
}
@ -71,29 +78,29 @@ struct image_t* S1_smoothen(struct image_t *input_image)
return smoother;
}
struct image_t* S2_find_details(struct image_t *input_image, struct image_t *smoothened_image)
struct image_t *S2_find_details(struct image_t *input_image, struct image_t *smoothened_image)
{
// TODO
int width = input_image->width;
int height = input_image->height;
struct image_t* details = new struct image_t;
struct image_t *details = new struct image_t;
details->height = height;
details->width = width;
details->image_pixels = new uint8_t**[height];
details->image_pixels = new uint8_t **[height];
for(int i = 0; i < height; i++)
for (int i = 0; i < height; i++)
{
details->image_pixels[i] = new uint8_t*[width];
for(int j = 0; j < width; j++)
details->image_pixels[i] = new uint8_t *[width];
for (int j = 0; j < width; j++)
details->image_pixels[i][j] = new uint8_t[3];
}
for(int i = 1; i < height-1; i++)
for (int i = 1; i < height - 1; i++)
{
for(int j = 1; j < width-1; j++)
for (int j = 1; j < width - 1; j++)
{
for(int k = 0; k < 3; k++)
for (int k = 0; k < 3; k++)
{
details->image_pixels[i][j][k] = max(0, input_image->image_pixels[i][j][k] - smoothened_image->image_pixels[i][j][k]);
}
@ -103,7 +110,7 @@ struct image_t* S2_find_details(struct image_t *input_image, struct image_t *smo
return details;
}
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
int width = input_image->width;
@ -111,122 +118,121 @@ struct image_t* S3_sharpen(struct image_t *input_image, struct image_t *details_
int a = 1;
struct image_t* sharp = new struct image_t;
struct image_t *sharp = new struct image_t;
sharp->height = height;
sharp->width = width;
sharp->image_pixels = new uint8_t**[height];
sharp->image_pixels = new uint8_t **[height];
for(int i = 0; i < height; i++)
for (int i = 0; i < height; i++)
{
sharp->image_pixels[i] = new uint8_t*[width];
for(int j = 0; j < width; j++)
sharp->image_pixels[i] = new uint8_t *[width];
for (int j = 0; j < width; j++)
sharp->image_pixels[i][j] = new uint8_t[3];
}
for(int i = 1; i < height-1; i++)
for (int i = 1; i < height - 1; i++)
{
for(int j = 1; j < width-1; j++)
for (int j = 1; j < width - 1; j++)
{
for(int k = 0; k < 3; k++)
for (int k = 0; k < 3; k++)
{
sharp->image_pixels[i][j][k] = min(255, input_image->image_pixels[i][j][k] + details_image->image_pixels[i][j][k]) * a;
}
}
}
return sharp; //TODO remove this line when adding your code
return sharp; // TODO remove this line when adding your code
}
uint8_t skip_blanks_comments_while_reading(ifstream *read_stream) //returns the byte at the first position after the skipping of the blank space
uint8_t skip_blanks_comments_while_reading(ifstream *read_stream) // returns the byte at the first position after the skipping of the blank space
{
uint8_t val;
while(true)
while (true)
{
val = read_stream->get();
if(val == '#')
if (val == '#')
{
while(val != '\n')
while (val != '\n')
{
val = read_stream->get();
}
}
if(val == '\n' || val == ' ' || val == '\t')
if (val == '\n' || val == ' ' || val == '\t')
{
continue;
}
else if(val != '#')
else if (val != '#')
return val;
}
return val;
}
struct image_t* read_ppm_file(char* path_to_input_file)
struct image_t *read_ppm_file(char *path_to_input_file)
{
//cout << "input image file = " << path_to_input_file << "\n";
// cout << "input image file = " << path_to_input_file << "\n";
ifstream read_stream(path_to_input_file, ios::binary | ios::in);
if(read_stream.is_open())
if (read_stream.is_open())
{
struct image_t* image = new struct image_t;
struct image_t *image = new struct image_t;
uint8_t val = skip_blanks_comments_while_reading(&read_stream); // 'P'
val = read_stream.get(); //'6'
// width
val = skip_blanks_comments_while_reading(&read_stream);
while(true)
while (true)
{
if(val == ' ' || val == '\t' || val == '\n')
if (val == ' ' || val == '\t' || val == '\n')
break;
image->width = image->width * 10 + (val - '0');
val = read_stream.get();
}
//cout << "width = " << image->width << "\n";
// cout << "width = " << image->width << "\n";
// height
val = skip_blanks_comments_while_reading(&read_stream);
while(true)
while (true)
{
if(val == ' ' || val == '\t' || val == '\n')
if (val == ' ' || val == '\t' || val == '\n')
break;
image->height = image->height * 10 + (val - '0');
val = read_stream.get();
}
//cout << "height = " << image->height << "\n";
// cout << "height = " << image->height << "\n";
image->image_pixels = new uint8_t**[image->height];
for(int i = 0; i < image->height; i++)
image->image_pixels = new uint8_t **[image->height];
for (int i = 0; i < image->height; i++)
{
image->image_pixels[i] = new uint8_t*[image->width];
for(int j = 0; j < image->width; j++)
image->image_pixels[i] = new uint8_t *[image->width];
for (int j = 0; j < image->width; j++)
image->image_pixels[i][j] = new uint8_t[3];
}
// maxval
val = skip_blanks_comments_while_reading(&read_stream);
while(true)
while (true)
{
if(val == ' ' || val == '\t' || val == '\n')
if (val == ' ' || val == '\t' || val == '\n')
break;
val = read_stream.get();
}
// get pixel values
val = skip_blanks_comments_while_reading(&read_stream);
for(int i = 0; i < image->height; i++)
for (int i = 0; i < image->height; i++)
{
for(int j = 0; j < image->width; j++)
for (int j = 0; j < image->width; j++)
{
for(int k = 0; k < 3; k++)
for (int k = 0; k < 3; k++)
{
image->image_pixels[i][j][k] = val;
val = read_stream.get(); //assuming maxval of <=255
val = read_stream.get(); // assuming maxval of <=255
}
}
}
//read_stream.seekg(-1, ios_base::cur);
//read_stream.read(((char*)image->image_pixels), image->height * image->width * 3); //assuming maxval of <=255
// read_stream.seekg(-1, ios_base::cur);
// read_stream.read(((char*)image->image_pixels), image->height * image->width * 3); //assuming maxval of <=255
read_stream.close();
@ -239,34 +245,34 @@ struct image_t* read_ppm_file(char* path_to_input_file)
}
}
void write_ppm_file(char * path_to_output_file, struct image_t* image)
void write_ppm_file(char *path_to_output_file, struct image_t *image)
{
//cout << "output image file = " << path_to_output_file << "\n";
// cout << "output image file = " << path_to_output_file << "\n";
ofstream write_stream(path_to_output_file, ios::binary | ios::out);
if(write_stream.is_open())
if (write_stream.is_open())
{
write_stream.write("P6\n", 3);
std::string width_string = std::to_string(image->width);
//cout << "width = " << width_string << "\n";
// cout << "width = " << width_string << "\n";
write_stream.write(width_string.c_str(), width_string.length());
write_stream.write(" ", 1);
std::string height_string = std::to_string(image->height);
//cout << "height = " << height_string << "\n";
// cout << "height = " << height_string << "\n";
write_stream.write(height_string.c_str(), height_string.length());
write_stream.write("\n255\n", 5);
for(int i = 0; i < image->height; i++)
for (int i = 0; i < image->height; i++)
{
for(int j = 0; j < image->width; j++)
for (int j = 0; j < image->width; j++)
{
for(int k = 0; k < 3; k++)
for (int k = 0; k < 3; k++)
{
write_stream.put(image->image_pixels[i][j][k]); //assuming maxval of <=255
write_stream.put(image->image_pixels[i][j][k]); // assuming maxval of <=255
}
}
}
//write_stream.write(((char*)image->image_pixels), image->height * image->width * 3);
// write_stream.write(((char*)image->image_pixels), image->height * image->width * 3);
write_stream.close();
}
else

View File

@ -1,38 +0,0 @@
../images/1.ppm 0.0436004
../images/2.ppm 0.200632
../images/3.ppm 0.142189
../images/4.ppm 0.328569
../images/5.ppm 0.584479
../images/6.ppm 1.57548
../images/7.ppm 1.44286
../images/1.ppm 0.0362725
../images/2.ppm 0.121128
../images/3.ppm 0.199664
../images/4.ppm 0.402522
../images/5.ppm 0.51656
../images/6.ppm 0.831204
../images/7.ppm 1.68258
../images/1.ppm 0.0502397
../images/2.ppm 0.0540259
../images/3.ppm 0.104212
../images/4.ppm 0.217633
../images/5.ppm 0.566316
../images/6.ppm 1.06233
../images/7.ppm 1.76924
../images/1.ppm 0.0191352
../images/2.ppm 0.0632993
../images/3.ppm 0.0990502
../images/4.ppm 0.304179
../images/5.ppm 0.306761
../images/6.ppm 0.740531
../images/7.ppm 1.62881
../images/1.ppm 0.0369097
../images/2.ppm 0.113096
../images/3.ppm 0.26913
../images/4.ppm 0.30726
../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
../images/3.ppm 0.199503

View File

@ -1,24 +0,0 @@
#!/bin/bash
# List of input and output file pairs
input_files=("1" "2" "3" "4" "5" "6" "7")
output_files=("output1" "output2" "output3" "output4" "output5" "output6" "output7")
# Loop through each file pair and run the make command
for i in "${!input_files[@]}"
do
input_file="${input_files[$i]}"
output_file="${output_files[$i]}"
echo "Running make for input: $input_file and output: $output_file"
make run-sharpen INPUT="$input_file" OUTPUT="$output_file"
# Check if make was successful
if [ $? -ne 0 ]; then
echo "Make failed for input: $input_file and output: $output_file"
exit 1
fi
done
echo "Make completed successfully for all file pairs."

View File

@ -1,38 +0,0 @@
../images/1.ppm 0.0285746
../images/2.ppm 0.118526
../images/3.ppm 0.133181
../images/4.ppm 0.333111
../images/5.ppm 0.687696
../images/6.ppm 0.919815
../images/7.ppm 5.18353
../images/1.ppm 0.0278552
../images/2.ppm 0.080822
../images/3.ppm 0.201076
../images/4.ppm 0.509533
../images/5.ppm 0.535679
../images/6.ppm 0.747966
../images/7.ppm 4.45165
../images/1.ppm 0.0100292
../images/2.ppm 0.0381673
../images/3.ppm 0.0739177
../images/4.ppm 0.223357
../images/5.ppm 0.433985
../images/6.ppm 0.450129
../images/7.ppm 1.67468
../images/1.ppm 0.0115579
../images/2.ppm 0.040362
../images/3.ppm 0.0973441
../images/4.ppm 0.257049
../images/5.ppm 0.231088
../images/6.ppm 0.573983
../images/7.ppm 2.23737
../images/1.ppm 0.0226699
../images/2.ppm 0.0941006
../images/3.ppm 0.146761
../images/4.ppm 0.170653
../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
../images/3.ppm 0.0578726

View File

@ -1,38 +0,0 @@
../images/1.ppm 0.0422791
../images/2.ppm 0.118747
../images/3.ppm 0.26533
../images/4.ppm 0.377423
../images/5.ppm 0.673011
../images/6.ppm 1.36309
../images/7.ppm 2.34904
../images/1.ppm 0.0396053
../images/2.ppm 0.14362
../images/3.ppm 0.398949
../images/4.ppm 0.59141
../images/5.ppm 0.730647
../images/6.ppm 0.869892
../images/7.ppm 2.32653
../images/1.ppm 0.0165813
../images/2.ppm 0.102202
../images/3.ppm 0.143081
../images/4.ppm 0.43276
../images/5.ppm 0.646602
../images/6.ppm 1.36732
../images/7.ppm 2.33917
../images/1.ppm 0.0341145
../images/2.ppm 0.079444
../images/3.ppm 0.163173
../images/4.ppm 0.501014
../images/5.ppm 0.52402
../images/6.ppm 1.03143
../images/7.ppm 2.75437
../images/1.ppm 0.0347922
../images/2.ppm 0.166539
../images/3.ppm 0.287508
../images/4.ppm 0.495099
../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
../images/3.ppm 0.0992293

View File

@ -1,26 +0,0 @@
import os
from collections import defaultdict
file_names = ["read_times.txt", "sharp_times.txt", "smooth_times.txt", "detail_times.txt", "write_times.txt"]
def calculate_average_times(file_path):
times = defaultdict(list)
with open(file_path, 'r') as file:
for line in file:
parts = line.strip().split()
if len(parts) == 2:
image, time = parts
times[image].append(float(time))
average_times = {image: sum(time_list) / len(time_list) for image, time_list in times.items()}
return average_times
for file_name in file_names:
average_times = calculate_average_times(file_name)
print(f"Averages for {file_name}:")
for image, avg_time in sorted(average_times.items()):
print(f"{image}: {avg_time}")
print()

View File

@ -1,38 +0,0 @@
../images/1.ppm 0.0129698
../images/2.ppm 0.0731423
../images/3.ppm 0.0586685
../images/4.ppm 0.391597
../images/5.ppm 0.441327
../images/6.ppm 0.362438
../images/7.ppm 1.01397
../images/1.ppm 0.0104656
../images/2.ppm 0.0389386
../images/3.ppm 0.102665
../images/4.ppm 0.229473
../images/5.ppm 0.370227
../images/6.ppm 0.359944
../images/7.ppm 1.65748
../images/1.ppm 0.00587877
../images/2.ppm 0.0390165
../images/3.ppm 0.0345854
../images/4.ppm 0.0927168
../images/5.ppm 0.184159
../images/6.ppm 0.231483
../images/7.ppm 1.05401
../images/1.ppm 0.00660735
../images/2.ppm 0.0207068
../images/3.ppm 0.0402921
../images/4.ppm 0.0976897
../images/5.ppm 0.119102
../images/6.ppm 0.249217
../images/7.ppm 0.822115
../images/1.ppm 0.0164718
../images/2.ppm 0.0259248
../images/3.ppm 0.0545286
../images/4.ppm 0.10985
../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
../images/3.ppm 0.152686