ImageProcessing / source / main.cpp
main.cpp
Raw
#include <iostream>
#include <fstream>
#include<sstream>
#include <filesystem>
using namespace std;
#include "Header.h"
#include"Pixel.h"
#include <vector>


//Function to compare output and example Pixel


//Function to compare output and example images' Header
void compare(Header& A, Header& B,vector<Pixel*>&output, vector<Pixel*>&example){
    if(A.idLength == B.idLength){
        cout << "1. same" << endl;
    }
    if(A.idLength == B.idLength){
        cout << "2. same" << endl;
    }
    if(A.colorMapType == B.colorMapType){
        cout << "3. same" << endl;
    }
    if(A.dataTypeCode == B.dataTypeCode){
        cout << "4. same" << endl;
    }
    if(A.colorMapOrigin == B.colorMapOrigin){
        cout << "5. same" << endl;
    }
    if(A.colorMapLength == B.colorMapLength){
        cout << "6. same" << endl;
    }
    if(A.colorMapDepth == B.colorMapDepth){
        cout << "7. same" << endl;
    }
    if(A.xOrigin == B.xOrigin){
        cout << "8. same" << endl;
    }
    if(A.yOrigin == B.yOrigin){
        cout << "9. same" << endl;
    }
    if(A.width == B.width){
        cout << "10. same" << endl;
    }
    if(A.height == B.height){
        cout << "11. same" << endl;
    }
    if(A.bitsPerPixel == B.bitsPerPixel){
        cout << "12. same"<< endl;
    }
    if(A.imageDescriptor == B.imageDescriptor){
        cout << "13. same" << endl;
    }
    cout << "Pixel_s output: " << output.size() << endl;
    cout << "Pixel_s example: " << example.size() << endl;

    for(unsigned int i = 0; i < output.size(); i++){
        if(output.at(i)->red != example.at(i)->red){
            cout << "Red Pixel at " << i << " is wrong" << endl;
        }
        if(output.at(i)->green != example.at(i)->green){
            cout << "Green Pixel at " << i << " is wrong" << endl;
        }
        if(output.at(i)->blue != example.at(i)->blue){
            cout << "Blue Pixel at " << i << " is wrong" << endl;
        }
    }
}


//Function to get Header data and Pixel data
vector<Pixel*> GetData(const string& filePath, Header& obj, vector<Pixel*> &data){
    ifstream inFile(filePath, ios_base::binary);

    if(inFile.is_open()){
        //Header data
        inFile.read(&obj.idLength, sizeof(obj.idLength));
        inFile.read(&obj.colorMapType, sizeof(obj.colorMapType));
        inFile.read(&obj.dataTypeCode, sizeof(obj.dataTypeCode));
        inFile.read((char*)&obj.colorMapOrigin,sizeof(obj.colorMapOrigin));
        inFile.read((char*)&obj.colorMapLength,sizeof(obj.colorMapLength));
        inFile.read((char*)&obj.colorMapDepth,sizeof(obj.colorMapDepth));
        inFile.read((char*)&obj.xOrigin,sizeof(obj.xOrigin));
        inFile.read((char*)&obj.yOrigin,sizeof(obj.yOrigin));
        inFile.read((char*)&obj.width, sizeof(obj.width));
        inFile.read((char*)&obj.height, sizeof(obj.height));
        inFile.read((char*)&obj.bitsPerPixel, sizeof(obj.bitsPerPixel));
        inFile.read((char*)&obj.imageDescriptor, sizeof(obj.imageDescriptor));
       /* cout << "Id Length: " << (int)obj.idLength << endl;
        cout << "Color Map Type: " <<(int) obj.colorMapType << endl;
        cout << "data Type Code: " << (int)obj.dataTypeCode << endl;
        cout << "color Map Origin: " << obj.colorMapOrigin << endl;
        cout << "Color Map Length: " << obj.colorMapLength << endl;
        cout << "Color Map Depth:" << (int)obj.colorMapDepth<< endl;
        cout << "xOrigin: " << obj.xOrigin << endl;
        cout << "yOrigin: " << obj.yOrigin << endl;
        cout << "Width: " << obj.width << endl;
        cout << "Height: " << obj.height << endl;
        cout << "Bits per Pixel: " << (int)obj.bitsPerPixel << endl;
        cout << "Image Descriptor: " << (int)obj.imageDescriptor << endl << endl;*/

        for(unsigned int i = 0; i < (int)(obj.width * obj.height); i++){
            Pixel* t = new Pixel;
            inFile.read((char*)&t->red, 1);
            inFile.read((char*)&t->green, 1);
            inFile.read((char*)&t->blue, 1);
            data.push_back(t);
        }


        inFile.close();

    }
    return data;

}

vector<Pixel*> multiply(vector<Pixel*> &first, vector<Pixel*> &second){
    vector<Pixel*> result;

    for(unsigned int i = 0; i < first.size(); i++){

        auto* t = new Pixel;
        // Get red Pixels from each image
        float red_1 = first.at(i)->red;
        float red_2 = second.at(i)->red;
        // Get blue Pixels from each image
        float blue_1 = first.at(i)->blue;
        float blue_2 = second.at(i)->blue;
        // Get green Pixels from each image
        float green_1 = first.at(i)->green;
        float green_2 = second.at(i)->green;

        //Create new Pixels which multiplies them

        t->red = ((red_1*red_2)/(float)255) + 0.5f;
        t->blue = ((blue_1*blue_2)/(float)255) + 0.5f;
        t->green = ((green_1*green_2)/(float)255) + 0.5f;

        //push new Pixels in vector result
        result.push_back(t);

    }
    // cout << result.at(50)->red << endl;
    // cout << "Done multiplying!" << endl;
    return result;

}
//task 2 - subtract
vector<Pixel*> subtract(vector<Pixel*> &first, vector<Pixel*> &second){
    vector<Pixel*> result;
    for(unsigned int i = 0; i < second.size(); i++){
        Pixel* t = new Pixel;
        // Get red Pixels from each image
        float red_1 = second.at(i)->red;
        float red_2 = first.at(i)->red;
        // Get blue Pixels from each image
        float blue_1 = second.at(i)->blue;
        float blue_2 = first.at(i)->blue;
        // Get green Pixels from each image
        float green_1 = second.at(i)->green;
        float green_2 = first.at(i)->green;

        //Create new Pixels which subtracts them
        // make sure they don't underflow i.e min value = 0
        if(red_1 - red_2 == 0 || red_1 - red_2 < 0){
            t->red = 0;
        } else {
            t->red = ((red_1 - red_2)) + 0.5f;
        }

        if(blue_1 - blue_2 == 0 || blue_1 - blue_2 < 0){
            t->blue = 0;
        } else {
            t->blue = ((blue_1 - blue_2)) + 0.5f;
        }

        if(green_1 - green_2 == 0 || green_1 - green_2 < 0){
            t->green = 0;
        } else {
            t->green = ((green_1 - green_2)) + 0.5f;
        }
        //push new Pixels in vector result
        result.push_back(t);

    }
    return result;
}

//Screen - task 3
vector<Pixel*> screen(vector<Pixel*> &temp, vector<Pixel*> &lead){
    vector<Pixel*> result;

    for(unsigned int i = 0; i < lead.size(); i++){
        Pixel* t = new Pixel;
        // Get red Pixels from each image
        float red_1 = (temp.at(i)->red)/(float)255;
        float red_2 = (lead.at(i)->red)/(float)255;
        // Get blue Pixels from each image
        float blue_1 = (temp.at(i)->blue)/(float)255;
        float blue_2 = (lead.at(i)->blue)/(float)255;
        // Get green Pixels from each image
        float green_1 = (temp.at(i)->green)/(float)255;
        float green_2 = (lead.at(i)->green)/(float)255;

        //Create new Pixels which screens them
        t->red = (1-((float)1 -(red_1))*((float)1 - (red_2)))*255 + 0.5f;
        t->blue = (1-((float)1 -(blue_1))*((float)1 - (blue_2)))*255 + 0.5f;
        t->green = (1-((float)1 - (green_1))*((float)1 - (green_2)))*255 + 0.5f;

        //push new Pixels in vector result
        result.push_back(t);

    }
    // cout << "Done screening!" << endl;
    return result;
}
//Overlay - task 5 RGB = 50, then grey

vector<Pixel*> overlay(vector<Pixel*> &bottom, vector<Pixel*> &top){
    
    vector<Pixel*> result;
    
    for(unsigned int i = 0; i < bottom.size(); i++){
        Pixel* t = new Pixel;
        // Get red Pixels from each image
        float red_1 = (bottom.at(i)->red)/(float)255;
        float red_2 = (top.at(i)->red)/(float)255;
        // Get blue Pixels from each image
        float blue_1 = (bottom.at(i)->blue)/(float)255;
        float blue_2 = (top.at(i)->blue)/(float)255;
        // Get green Pixels from each image
        float green_1 = (bottom.at(i)->green)/(float)255;
        float green_2 = (top.at(i)->green)/(float)255;
        
        if(red_1 <= 0.5){
            //Create new Pixels which multiplies them
            t->red = (float)2*((red_1 * red_2))*255 + 0.5f;
        } else{
            //Create new Pixels which screens them
            t->red = (1.0f - (2.0f *(1.0f - red_1) * (1.0f - red_2) )) *255 + 0.5f;
        }
        if(blue_1 <= 0.5){
            //Create new Pixels which multiplies them
            t->blue = (float)2*((blue_1*blue_2))*255 + 0.5f;
        } else{
            //Create new Pixels which screens them
            t->blue = (1.0f - (2.0f *(1.0f - blue_1) * (1.0f - blue_2) )) *255 + 0.5f;
        }
        if(green_1 <= 0.5){
            //Create new Pixels which multiplies them
            t->green = (float)2*((green_1* green_2))*255 + 0.5f;
        } else{
            //Create new Pixels which screens them
            t->green = (1.0f - (2.0f *(1.0f - green_1) * (1.0f - green_2) )) *255 + 0.5f;
        }
        result.push_back(t);

    }
    
    //cout << result.at(50)->red << endl;
    //cout << "Done overlaying!" << endl;
    
    return result;
    
}

// AddGreen by +200 - task 6
vector<Pixel*> AddGreen(vector<Pixel*> &T){
    vector<Pixel*> result;
    
    for(unsigned int i = 0; i < T.size(); i++){
        Pixel* t = new Pixel;
        // Get red Pixels from the image
        float red_1 = T.at(i)->red;
        // Get blue Pixels from the image
        float blue_1 = T.at(i)->blue;
        // Get green Pixels from the image
        float green_1 = T.at(i)->green;
        
        //Create new Pixels which multiplies them
        t->red = ((red_1)) + 0.5f;
        t->blue = ((blue_1)) + 0.5f;
        if(green_1 < 55){
            t->green = (((green_1 + (float)200))) + 0.5f;
        } else {
            t->green = 255;
        }

        //push new Pixels in vector result
        result.push_back(t);

    }
    //cout << result.at(50)->red << endl;
    //cout << "Done adding green!" << endl;
    return result;
    
}

//Multiply red and blue channels - one file
vector<Pixel*> multiply1(vector<Pixel*> &one){
    vector<Pixel*> result;
    
    for(unsigned int i = 0; i < one.size(); i++){
        Pixel* t = new Pixel;
        // Get red Pixels from each image
        float red_1 = one.at(i)->red;
        // Get blue Pixels from each image
        float blue_1 = one.at(i)->blue;
        // Get green Pixels from each image
        float green_1 = one.at(i)->green;
        
        //Create new Pixels which multiplies them
        if(blue_1 < (float)255/4){
            t->blue = (blue_1*4) + 0.5f;
        } else{
            t->blue = 255 + 0.5f;
        }
        
        t->red = (red_1*0) + 0.5f;
        t->green = (green_1) + 0.5f;

        //push new Pixels in vector result
        result.push_back(t);

    }
    //cout << result.at(50)->red << endl;
    //cout << "Done multiplying!" << endl;
    return result;
    
}

//Get only the red channel - task 8
vector<Pixel*> redChannel(vector<Pixel*> &one){
    vector<Pixel*> result;
    
    for(unsigned int i = 0; i < one.size(); i++){
        Pixel* t = new Pixel;
        // Get red Pixels from each image
        float red_1 = one.at(i)->blue;
        float red_2 = one.at(i)->blue;
        float red_3 = one.at(i)->blue;
                
        //Create new Pixels which multiplies them
       
        t->red =  red_1;
        t->green = red_2;
        t->blue = red_3;

        //push new Pixels in vector result
        result.push_back(t);

    }
    //  cout << result.at(50)->red << endl;
    //  cout << "Done red channel!" << endl;
    return result;
    
}

//Get only the green channel - task 8
vector<Pixel*> greenChannel(vector<Pixel*> &one){
    vector<Pixel*> result;
    
    for(unsigned int i = 0; i < one.size(); i++){
        Pixel* t = new Pixel;
        // Get red Pixels from each image
        float green_1 = one.at(i)->green;
        float green_2 = one.at(i)->green;
        float green_3 = one.at(i)->green;
                
        //Create new Pixels which multiplies them
       
        t->red =  green_1;
        t->green = green_2;
        t->blue = green_3;

        //push new Pixels in vector result
        result.push_back(t);

    }
    // cout << result.at(50)->red << endl;
    // cout << "Done green channel!" << endl;
    return result;
    
}

//Get only the blue channel - task 8
vector<Pixel*> blueChannel(vector<Pixel*> &one){
    vector<Pixel*> result;
    
    for(unsigned int i = 0; i < one.size(); i++){
        Pixel* t = new Pixel;
        // Get red Pixels from each image
        float blue_1 = one.at(i)->red;
        float blue_2 = one.at(i)->red;
        float blue_3 = one.at(i)->red;
                 
        //Create new Pixels which multiplies them
       
        t->red =  blue_1;
        t->green = blue_2;
        t->blue = blue_3;

        //push new Pixels in vector result
        result.push_back(t);

    }
    
    return result;
    
}
//Combine - task 9 - input as red, green, blue
vector<Pixel*> Combine(vector<Pixel*> &one,vector<Pixel*> &two,vector<Pixel*> &three){
    vector<Pixel*> result;

    for(unsigned int i = 0; i < one.size(); i++){
        Pixel* t = new Pixel;
        // Get red Pixels from each image
        float red_1 = one.at(i)->red;
        float green_1 = two.at(i)->green;
        float blue_1 = three.at(i)->blue;
                 
        //Create new Pixels which multiplies them
       
        t->red =  red_1;
        t->green = green_1;
        t->blue = blue_1;

        //push new Pixels in vector result
        result.push_back(t);

    }
    return result;
    
}

vector<Pixel*> rotate(vector<Pixel*> &one){
    vector<Pixel*> Forwardresult;

    for(unsigned int i = 0; i < one.size(); i++){
        Pixel* t = new Pixel;
        // Get red Pixels from each image
        float red_1 = one.at(i)->red;
        float green_1 = one.at(i)->green;
        float blue_1 = one.at(i)->blue;
                 
        //Create new Pixels which multiplies them
       
        t->red =  red_1;
        t->green = green_1;
        t->blue = blue_1;

        //push new Pixels in vector result
        Forwardresult.push_back(t);

    }
    vector<Pixel*> result;
    for(unsigned int i = 0; i < Forwardresult.size(); i++){
        Pixel* t = new Pixel;
        // Get red Pixels from each image
        float red_1 = Forwardresult.at(Forwardresult.size()-i-1)->red;
        float green_1 = Forwardresult.at(Forwardresult.size()-i-1)->green;
        float blue_1 = Forwardresult.at(Forwardresult.size()-i-1)->blue;
                 
        //Create new Pixels which multiplies them
       
        t->red =  red_1;
        t->green = green_1;
        t->blue = blue_1;

        //push new Pixels in vector result
        result.push_back(t);

    }

    return result;
    
}

void quadrants(vector<Pixel*> &first,vector<Pixel*> &second,vector<Pixel*> &third,vector<Pixel*> &fourth, vector<vector<Pixel*>> &vec){
    for(unsigned int i = 0; i < 1024; i++){
        vector<Pixel*> temp;
        for(unsigned int j = 0; j < 1024; j++ ){
            Pixel* t = new Pixel;
            t->red = (unsigned char)0;
            t->green = (unsigned char)0;
            t->blue = (unsigned char)0;
            temp.push_back(t);
        }
        vec.push_back(temp);

    }
    int iterator = 0;
    
    for(unsigned int i = 0; i < 512; i++){
        for(unsigned int j = 0; j < 512; j++){
            vec.at(i).at(j)->red = first.at(iterator)->red;
            vec.at(i).at(j)->green = first.at(iterator)->green;
            vec.at(i).at(j)->blue = first.at(iterator)->blue;
            iterator++;
           
        }
   
    }
    iterator = 0;
    for(unsigned int i = 0; i < 512; i++){
        for(unsigned int j = 512; j < 1024; j++){
            vec.at(i).at(j)->red = second.at(iterator)->red;
            vec.at(i).at(j)->green = second.at(iterator)->green;
            vec.at(i).at(j)->blue = second.at(iterator)->blue;
            iterator++;
           
        }
   
    }
    iterator = 0;
    for(unsigned int i = 512; i < 1024; i++){
        for(unsigned int j = 512; j < 1024; j++){
            vec.at(i).at(j)->red = third.at(iterator)->red;
            vec.at(i).at(j)->green = third.at(iterator)->green;
            vec.at(i).at(j)->blue = third.at(iterator)->blue;
            iterator++;
           
        }
   
    }
    iterator = 0;
    for(unsigned int i = 512; i < 1024; i++){
        for(unsigned int j = 0; j < 512; j++){
            vec.at(i).at(j)->red = fourth.at(iterator)->red;
            vec.at(i).at(j)->green = fourth.at(iterator)->green;
            vec.at(i).at(j)->blue = fourth.at(iterator)->blue;
            iterator++;
           
        }
   
    }
    
    
    
}

void writeDataQuad (string filePath, vector<vector<Pixel*>>& n, Header& obj){

    ofstream inFile(filePath, ios_base::binary);
     
    if(inFile.is_open()){
        // cout << "File opened to write data" << endl;
        //Header data
        obj.width = 1024;
        obj.height = 1024;
         
        inFile.write(&obj.idLength, sizeof(obj.idLength));
        inFile.write(&obj.colorMapType, sizeof(obj.colorMapType));
        inFile.write(&obj.dataTypeCode, sizeof(obj.dataTypeCode));
        inFile.write((char*)&obj.colorMapOrigin,sizeof(obj.colorMapOrigin));
        inFile.write((char*)&obj.colorMapLength,sizeof(obj.colorMapLength));
        inFile.write((char*)&obj.colorMapDepth,sizeof(obj.colorMapDepth));
        inFile.write((char*)&obj.xOrigin,sizeof(obj.xOrigin));
        inFile.write((char*)&obj.yOrigin,sizeof(obj.yOrigin));
        inFile.write((char*)&obj.width, sizeof(obj.width));
        inFile.write((char*)&obj.height, sizeof(obj.height));
        inFile.write((char*)&obj.bitsPerPixel, sizeof(obj.bitsPerPixel));
        inFile.write((char*)&obj.imageDescriptor, sizeof(obj.imageDescriptor));
        //cout << "Height: " << obj.height << endl;
        //cout << "Width: " << obj.width << endl;
         
        // Image data
        
         
        for(unsigned int i = 0; i < 1024; i++){
            for(unsigned int j = 0; j < 1024; j++){
                inFile.write((char*)&n.at(i).at(j)->red, 1);
                inFile.write((char*)&n.at(i).at(j)->green, 1);
                inFile.write((char*)&n.at(i).at(j)->blue, 1);
            }
        
        }
         
        
         
         
        
        
         

        // cout << "Done writing!";
        inFile.close();
    
    }
}




void writeData (string filePath, vector<Pixel*>& r, Header& obj){

    ofstream inFile(filePath, ios_base::binary);

    if(inFile.is_open()){
        // cout << "File opened to write data" << endl;
        //Header data
        inFile.write(&obj.idLength, sizeof(obj.idLength));
        inFile.write(&obj.colorMapType, sizeof(obj.colorMapType));
        inFile.write(&obj.dataTypeCode, sizeof(obj.dataTypeCode));
        inFile.write((char*)&obj.colorMapOrigin,sizeof(obj.colorMapOrigin));
        inFile.write((char*)&obj.colorMapLength,sizeof(obj.colorMapLength));
        inFile.write((char*)&obj.colorMapDepth,sizeof(obj.colorMapDepth));
        inFile.write((char*)&obj.xOrigin,sizeof(obj.xOrigin));
        inFile.write((char*)&obj.yOrigin,sizeof(obj.yOrigin));
        inFile.write((char*)&obj.width, sizeof(obj.width));
        inFile.write((char*)&obj.height, sizeof(obj.height));
        inFile.write((char*)&obj.bitsPerPixel, sizeof(obj.bitsPerPixel));
        inFile.write((char*)&obj.imageDescriptor, sizeof(obj.imageDescriptor));
        //cout << "Height: " << obj.height << endl;
        //cout << "Width: " << obj.width << endl;
        int size = obj.height * obj.width;
        // Image data
        for(unsigned int i = 0; i < size; i++){
            inFile.write((char*)&r.at(i)->red, 1);
            inFile.write((char*)&r.at(i)->green, 1);
            inFile.write((char*)&r.at(i)->blue, 1);

        }

        // cout << "Done writing!";
        inFile.close();

    }
}


//Write data
int main() {
    // First Image
    vector<Pixel*> first;
    Header one;

    //Second Image
    vector<Pixel*> second;
    Header two;

    //Third image if applicable
    vector<Pixel*> third;
    Header three;

    //Fourth image if applicable
    vector<Pixel*> fourth;
    Header four;

    //temporary image Pixel storer
    vector<Pixel*> temp;

    //Resultant Image
    vector<Pixel*> result;
    Header r;

    vector<Pixel*> result2;

    //==================================TASK1==========================================

    // Use the multiply blending mode to combine "layer1.tga"(6) (top layer) with
    // "pattern1.tga" (8)(bottom layer)


    //load layer1 data

    GetData("input/layer1.tga",  one, first); //header data


    //load pattern1 data

    GetData("input/pattern1.tga",  two, second);

    //Multiply

    result = multiply(first,second);
    //Write data
    writeData("output/part1.tga", result, one);

    Header A;
    Header B;

    vector<Pixel*> output;
    vector<Pixel*> example;

    GetData("output/part1.tga", A, output);

    GetData("examples/EXAMPLE_part1.tga", B, example);

    compare(A,B,output,example);
    output.clear();
    example.clear();



    result.clear();
    first.clear();
    second.clear();

    //==================================TASK2==========================================

    // Use the subtract mode to combine layer1(TL) with car(BL) BL - TL

    //load layer2 data
    GetData("input/layer2.tga", one,first); //header data

    //load car data
    GetData("input/car.tga", two,second);

    //Subtract
    result = subtract(first,second);
    //bottom - top
    //Write data
    writeData("output/part2.tga", result, two);


    GetData("output/part2.tga", A, output);

    GetData("examples/EXAMPLE_part2.tga", B, example);

    compare(A,B,output,example);
    output.clear();
    example.clear();


    result.clear();
    first.clear();
    second.clear();

      //==================================TASK3===========================================

      //Use the multiply blending mode to combine layer 1 and pattern 2
      //Store the results - temp image
      //load txt image and combine with temp image using screen mode


      //load layer1 data

      GetData("input/layer1.tga",one,first); //header and Pixel data
      //load pattern2 data

      GetData("input/pattern2.tga", two, second);

      //Multiply
      temp = multiply(first,second); //temp pix vector

      //Load txt image
      GetData("input/text.tga", three, third); //header and Pixel vector

      //Screen temp and txt
      result = screen(third,temp);

      //Write data
      writeData("output/part3.tga", result, three);

      GetData("output/part3.tga", A, output);

      GetData("examples/EXAMPLE_part3.tga", B, example);

      compare(A,B,output,example);
      output.clear();
      example.clear();


      result.clear();
      first.clear();
      second.clear();
      third.clear();

      //==================================TASK4===========================================

      //Multiply layer2 with circles and store it. - temp image - bottom
      //Load pattern2 and use it as top layer
      // Use subtract - bottom - top


      //load layer2 data

      GetData("input/layer2.tga", one,first); //header data

      //load circles data

      GetData("input/circles.tga", two,second);

      //Multiply
      temp = multiply(first,second); //temp pix vector

      //Load pattern2 image
      GetData("input/pattern2.tga", three, third); //header data

      //Subtract temp and pattern2
      result = subtract(third,temp);

      //Write data
      writeData("output/part4.tga", result, three);

      GetData("output/part4.tga", A, output);

      GetData("examples/EXAMPLE_part4.tga", B, example);

      compare(A,B,output,example);
      output.clear();
      example.clear();



      result.clear();
      first.clear();
      second.clear();
      third.clear();

      //==================================TASK5==========================================

      // Combine layer1(top layer) with pattern1 using the //overlay mode

      //load layer1 data
      GetData("input/layer1.tga", one,first); //header data

      //load pattern1 data
      GetData("input/pattern1.tga", two,second);

      //Overlay
      result = overlay(second,first);
      //Write data
      writeData("output/part5.tga", result, two);

      GetData("output/part5.tga", A, output);

      GetData("examples/EXAMPLE_part5.tga", B, example);

      compare(A,B,output,example);
      output.clear();
      example.clear();



      result.clear();
      first.clear();
      second.clear();

      //==================================TASK6==========================================

      //Load car.tga and add 200 to the green channel

      //load car data
      GetData("input/car.tga", one,first); //header data

      //Add green
      result = AddGreen(first);
      //Write data
      writeData("output/part6.tga", result, one);

      GetData("output/part6.tga", A, output);

      GetData("examples/EXAMPLE_part6.tga", B, example);

      compare(A,B,output,example);
      output.clear();
      example.clear();


      result.clear();

      //==================================TASK7==========================================
      // Multiply the red channel by 4 and the blue channel by 0. Same file(car.tga)

      result = multiply1(first);
      writeData("output/part7.tga", result, one);

      GetData("output/part7.tga", A, output);

      GetData("examples/EXAMPLE_part7.tga", B, example);

      compare(A,B,output,example);
      output.clear();
      example.clear();


      result.clear();



      //==================================TASK8==========================================
      //Part 1
      // Load car.tga and write red channel to its separate file
      result = redChannel(first);
      writeData("output/part8_r.tga", result, one);

      GetData("output/part8_r.tga", A, output);

      GetData("examples/EXAMPLE_part8_r.tga", B, example);

      compare(A,B,output,example);
      output.clear();
      example.clear();


      result.clear();

      //Part 2
      //Load car.tga and write green channel to its separate file
      result = greenChannel(first);
      writeData("output/part8_g.tga", result, one);

      GetData("output/part8_g.tga", A, output);

      GetData("examples/EXAMPLE_part8_g.tga", B, example);

      compare(A,B,output,example);
      output.clear();
      example.clear();

      result.clear();

      //Part 3
      //Load car.tga and write blue channel to its separate file
      result = blueChannel(first);
      writeData("output/part8_b.tga", result, one);

      GetData("output/part8_b.tga", A, output);

      GetData("examples/EXAMPLE_part8_b.tga", B, example);

      compare(A,B,output,example);
      output.clear();
      example.clear();

      result.clear();

      first.clear();


      //==================================TASK9==========================================

      // Combine layer_red,green and blue and combine them

      //load layer_red data
      GetData("input/layer_red.tga", one,first); //header data

      //load layer_green data
      GetData("input/layer_green.tga", two,second);

      //load layer_blue data
      GetData("input/layer_blue.tga", three,third);

      //Combine
      result = Combine(third,second,first);
      //Write data
      writeData("output/part9.tga", result, two);

      GetData("output/part9.tga", A, output);

      GetData("examples/EXAMPLE_part9.tga", B, example);

      compare(A,B,output,example);
      output.clear();
      example.clear();


      result.clear();
      first.clear();
      second.clear();
      third.clear();


      //==================================TASK10==========================================
      //load text2.tga
      //rotate 180 degrees

      GetData("input/text2.tga", one,first); //header data

      //rotate
      result = rotate(first);
      writeData("output/part10.tga", result, one);

      GetData("output/part10.tga", A, output);

      GetData("examples/EXAMPLE_part10.tga", B, example);

      compare(A,B,output,example);
      output.clear();
      example.clear();

      result.clear();
      first.clear();


      //==================================EXTRACREDIT==========================================
      //load car,circles,pattern1 and text.
      //circles - 1st quadrant
      //pattern1 - 2nd quadrant
      //text - 3rd quadrent
      //car - 4th quadrant

      GetData("input/circles.tga", one, first); //header data

      GetData("input/pattern1.tga", two, second); //header data

      GetData("input/text.tga", three, third); //header data

      GetData("input/car.tga", four, fourth); //header data

      vector<vector<Pixel*>> ec;

      //Quadrant
      quadrants(third,second,first, fourth, ec);

      writeDataQuad("output/extracredit.tga", ec, one);

    GetData("output/extracredit.tga", A, output);

    GetData("examples/EXAMPLE_extracredit.tga", B, example);

    compare(A,B,output,example);
    output.clear();
    example.clear();


      result.clear();
      first.clear();


  }