Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help implementing the following function in assembly language not C plz h

ID: 3798102 • Letter: I

Question

I need help implementing the following function in assembly language not C plz help

// - This function takes in a square sized grayscale image and applies thresholding on each pixel.
//   i.e. it should change pixel values according to this formula:
//                     0xFF       if x >= threshold
//                     0x00       if x < threshold
// - The width and height of the image are equal to dim.
// - You are not allowed to define additional variables.
//
void imageThresholding(unsigned char* image, int dim, unsigned char threshold) {}

Explanation / Answer

Thresholding is a process of converting a grayscale input image to a bi-level image by using an optimal threshold.

thresholding purpose is to extract those pixels from some image which is represent an object (either text or other line image data such as graphs, maps). Though the information is binary the pixels represent a range of intensities therefore the objective of binarization is to mark pixels that belong to true foreground regions with a single intensity and background regions with different intensities.

There are two types of thresholding algorithms

Global thresholding algorithms, and

Local or adaptive thresholding algorithms

For global thresholding, a single threshold for all the image pixels is used and when the pixel values of the components and that of background are fairly consistent in their respective values over the entire image, global thresholding could be used.

asm {

mov eax, image

       mov edi, 0
       BEGIN_FOR_ROW:
       cmp edi, dim
           jge END_FOR_ROW
           mov esi, 0

           BEGIN_FOR_COL :
           cmp esi, dim
           jge END_FOR_COL
           mov ebx, 0 //Transfer row to ebx

           mov edx, 0 //Multiply row by dim (add row to row dim times)
           BEGIN_FOR_MUL :
           cmp edx, dim
           jge END_FOR_MUL
           add ebx, edi
           inc edx
           jmp BEGIN_FOR_MUL
           END_FOR_MUL :

       add ebx, esi
           xor edx, edx
           mov dl, [eax + ebx]
           mov cl, threshold
           and cl, dl
           cmp cl, 0x00
           jne IF_HIGHER
           xor edx, edx //set to Min
           jmp CONT
           IF_HIGHER :
       or edx, 0xFF
           CONT :
           mov[eax + ebx], dl
           inc esi
           jmp BEGIN_FOR_COL

           END_FOR_COL :
       inc edi
           jmp BEGIN_FOR_ROW

           END_FOR_ROW :
       mov image, eax

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote