CharLie071005 / OOP_final_project

MIT License
1 stars 0 forks source link

Bit Field Improvement #3

Closed coherent17 closed 2 months ago

coherent17 commented 2 months ago

define GRAY_BOX 0b00000001

define GRAY_Med 0b00000010

define GRAY_Sobel 0b00000100

define GRAY_Linear 0b00001000

define RGB_BOX 0b00010000

define RGB_Med 0b00100000

define RGB_Sobel 0b01000000

define RGB_Linear 0b10000000

since the image can only be gray or rgb, it's not able to perform option like 0b00010001 find some way to make this bit-field option better.

Ouzheee commented 2 months ago

Got it! Thanks for giveing advice. We will try to fix it.

coherent17 commented 2 months ago

Can you share how you are going to solve this?

Ouzheee commented 2 months ago

Sorry for unaware of this message and the hint in the Update bit field! I'm planning to use && to detect such condition. In other words, if the option has 1 in first four bit also another 1 in last four bit, it returns 0 and jump out of the LoadCase.

#define RGB 0b11110000
#define GRAY 0b00001111

if ((option & RGB && option & GRAY){
        cout << "Invalid option !" << endl;
        return false;
    }

About the comment in the Update bit field, I change the main.cpp like this

#include "image.h"
#include "gray_image.h"
#include "rgb_image.h"
#include "photo_mosaic.h"
#include "bit_field_filter.h"

#define GRAY_BOX    0b00000001
#define GRAY_Med    0b00000010
#define GRAY_Sobel  0b00000100
#define GRAY_Linear 0b00001000
#define RGB_BOX     0b00010000
#define RGB_Med     0b00100000
#define RGB_Sobel   0b01000000
#define RGB_Linear  0b10000000
#define ENABLE_X_SERVER false

int main(int argc, char *argv[]){

    Image *img1 = new GrayImage();
    img1->LoadImage("Image-Folder/mnist/img_100.jpg");
    img1->DumpImage("img1.jpg");
    if(ENABLE_X_SERVER){
        img1->Display_X_Server();
    }
    img1->Display_ASCII();
    img1->Display_CMD();

    //test bit filed
    if (loadCase(GRAY_Sobel | GRAY_Linear , img1)){
        img1->DumpImage("imgtest1.jpg");
        if(ENABLE_X_SERVER){
            img1->Display_X_Server();
        }
        img1->Display_ASCII();
        img1->Display_CMD();
    }

return 0;
}

Is that OK?

coherent17 commented 2 months ago

ok, I'll take this one. you can still think if there is a better way to do this!