0

I’m sure it is obvious for some people, but it wasn’t for me)

If your code isn’t working the way it should, you can create new .c file and put there your logic from edge detection function.

You can hardcode input from one of the test cases which your code isn’t passing and simplify task by finding Gx, Gy and new color value only for one color channel.

After that, using debug50 you go through your code step-by-step watching closely changing values of your variables)

debug50 is amazingly useful and powerful tool)

happy coding!

0

Well, good idea. I did this and actually figured out, that my program is perfectly working in a dedicated file with hardcode:

{rgbtBlue = 210, rgbtGreen = 150, rgbtRed = 60}

When I run the check50, it is doing wrong.

Hardcode:

int height = 3;
int width = 3;
RGBTRIPLE image[height][width];

image[0][0].rgbtRed = 25;
image[0][0].rgbtGreen = 10;
image[0][0].rgbtBlue = 0;

image[0][1].rgbtRed = 30;
image[0][1].rgbtGreen = 10;
image[0][1].rgbtBlue = 0;

image[0][2].rgbtRed = 80;
image[0][2].rgbtGreen = 60;
image[0][2].rgbtBlue = 40;

image[1][0].rgbtRed = 90;
image[1][0].rgbtGreen = 30;
image[1][0].rgbtBlue = 20;

image[1][1].rgbtRed = 100;
image[1][1].rgbtGreen = 40;
image[1][1].rgbtBlue = 30;

image[1][2].rgbtRed = 90;
image[1][2].rgbtGreen = 70;
image[1][2].rgbtBlue = 80;

image[2][0].rgbtRed = 40;
image[2][0].rgbtGreen = 20;
image[2][0].rgbtBlue = 20;

image[2][1].rgbtRed = 30;
image[2][1].rgbtGreen = 10;
image[2][1].rgbtBlue = 30;

image[2][2].rgbtRed = 10;
image[2][2].rgbtGreen = 40;
image[2][2].rgbtBlue = 50;

Any idea?

screenshot from check50

Debug50 result after middle pixel:

{{{rgbtBlue = 76, rgbtGreen = 117, rgbtRed = 255}, {rgbtBlue = 213, rgbtGreen = 228, rgbtRed = 255}, {rgbtBlue = 192, rgbtGreen = 190, rgbtRed = 255}}, {{rgbtBlue = 114, rgbtGreen = 102, rgbtRed = 255}, {rgbtBlue = 210, rgbtGreen = 150, rgbtRed = 60}, {rgbtBlue = 0, rgbtGreen = 0, rgbtRed = 0}}, {{rgbtBlue = 0, rgbtGreen = 0, rgbtRed = 0}, {rgbtBlue = 0, rgbtGreen = 0, rgbtRed = 0}, {rgbtBlue = 0, rgbtGreen = 0, rgbtRed = 0}}}
2
  • I've used 3d array instead of RGBTRIPLE: int image[3][3][3] = {{{0, 10, 25}, {0, 10, 30}, {40, 60, 80}}, {{20, 30, 90}, {30, 40, 100}, {80, 70, 90}},{{20, 20, 40}, {30, 10, 30}, {50, 40, 10}}}; also my code was getting Gx Gy only for BLUE, image[i][j][0], to simplify. and before that I draw a grid (input array) on a sheet of paper, made calculations (for BLUE) and written down all values for each iteration. after that with debug50 I've been checking values that my code generate for each iteration and compering them to mine, calculated by hand. hope it'll help) if not - post your code here
    – krayevska
    Apr 9 '20 at 12:51
  • weird though. same code, same input but different outputs
    – krayevska
    Apr 9 '20 at 15:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .