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. the given code is what I got bu

ID: 3796551 • Letter: I

Question

I need help implementing the following function. the given code is what I got but I know is wrong since when I tested it, the function fails. I need help plz

// - 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) {
__asm {

  // YOUR CODE STARTS HERE
  mov eax, dim     //////// this is my code and its wrong any help will do
  mul dim
  mov ebx, image
  mov ecx, 0

  BeginLoop:
  cmp eax, ecx
   jle EndofLoop
   mov dl, byte ptr[ebx + ecx]
   cmp dl, 0x80
   jae NextLoop
   mov dl, 0x00
   mov byte ptr[ebx + ecx], dl
   inc ecx
   jmp BeginLoop
   NextLoop :
  mov dl, 0xFF
   mov byte ptr[ebx + ecx], dl
   ADD ecx, 1
   jmp BeginLoop

   EndofLoop :
  // YOUR CODE ENDS HERE
}
system("pause");
}

Explanation / Answer

Mistakes which I observed are :-

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