Presentation is loading. Please wait.

Presentation is loading. Please wait.

Visual Info Processing Programming Guide (More Details)

Similar presentations


Presentation on theme: "Visual Info Processing Programming Guide (More Details)"— Presentation transcript:

1 Visual Info Processing Programming Guide (More Details)

2 Visual Studio 20XX Views Text window Output Build Debug
Solution-properties

3 Microsoft Foundation Class Library
Class is a concept in object-oriented programming. In our sample program, we majorly concern 2 classes. MFC represents Windows components (menus, dialogs) as classes. Why it's recommended to add the event handlers in the CKingImageView class?

4 Bitmap Format File Header: Image Data:
Type, size of file, reserved dword, offset to image data, size of header, width, height, color planes, color depth, compress flag, size of image data, horizontal resolution, vertical resolution, number of colors, important colors, RGB palettes. Image Data: The actual image data of the file. From bottom-left. Padding bytes. Use software to convert bitmap images.

5 Common bugs Using cout in MFC.
- Even if you use include iostream, it won’t work. - You can create your own command prompt. - Or simply use AfxMessageBox instead.

6 Common bugs Accuracy lost. int a=2, b=3;
int c = a/b; // It’s not going to be 0.667! Use double variables and convert them back to BYTE.

7 Common bugs If we have the code: double a,b; int c,d; b=2.5; c=5; d=10; a=c/d; If we run it, a will be 0. Because both c and d are integers, so c/d should result in an integer: 0.

8 Common bugs If we change the last line to a=b/d, the result will still be 0. Because the compiler will automatically convert the output type of division to the same type as the denominator. Here the denominator d is an integer. Thus the result of b/d will still be an integer: 0.

9 Common bugs If we have an integer number but want the compiler to recognize it as type double, we must add ".0" at the end of the integer. For example, 5 is of type int, but 5.0 is of type double. 2/5 will be 0, but 2/5.0 will be 0.4.

10 Common bugs So be careful using data type conversion.
Always use explicit conversion – casting. double g = grayscale; pImg[i*iWidth+j] = (BYTE) g; Check if the value of the grayscale is between 0 and 255! if (g < 0.0) g = 0.0; else if (g > 255.0) g = 255.0; else {…}

11 Common bugs Original image overwritten!
Define an array to store the image data. double *arr = new double ... ; for (…) { arr[i*iWidth+j] = (double) pImg[i*iWidth+j]; }

12 Common bugs Mask template. Use 2 arrays, one as input, one as output.

13 Verify your result. Compare your output image with professor’s examples. Use GIMP or Photoshop to verify your results. Use your eyes to verify your results.

14 Examples Draw a filled circle. Create a mirrored image.

15 Please ask as early as possible.
The End Questions? Please ask as early as possible.


Download ppt "Visual Info Processing Programming Guide (More Details)"

Similar presentations


Ads by Google