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

I need help with problem 5.......If you could help with 4 to, that would be grea

ID: 3833642 • Letter: I

Question

I need help with problem 5.......If you could help with 4 to, that would be great

Problem 4 20 points) Given a 2-D signal xin, ml the Roberts edge detector and g2lni, n2 as shown, all pixels shown in xlnu,n2l have value of 1. 1) Calculate the 2 convolution of yilni, -xIni, n21 giln, n2l, n2 2) Calculate the 2-D convolution of ynlni, xln, ml gzlni, nzl, nzl 3) Sum up the absolution values of these two outputs as Jlni, nzl- vilni, nzll bilni, nell, which should become the detected edge image. (Important: show your steps in all calculations.) x[ni, nj 1 m 0 1 ni

Explanation / Answer

Question 5 Answer:-

The Robert edge filter is mainly used to detect the overall edges of an image by assigning the horizontal and verticle filter at a time for a better result.

Horizontal Filter:

I have created a small table which tells you about the horizontal filter.

Vertical Filter:

I have created a small table which tells you about the verical filter.

Now, Lets write the C++ routine for Roberts Edge Detector:

Program:-


// The header files contains the objects and properties

#include <iostream>
#include <fstream>
#include <cstdlib>
#include <cmath>
#include <string>

using namespace std;


class robertEdgePixel
{
private:

// Created the pixel variables
  
unsigned int P1, P2, P3;


public:

// Assigned the three pixel values

robertEdgePixel () {};
void robertSetEdges (unsigned int edgePixel1, unsigned int edgePixel2, unsigned int edgePixel3);
unsigned int getPixel1 ();
unsigned int getPixel2 ();
unsigned int getPixel3 ();
};

// Initiated the method with 3 pixel parameters

void robertEdgePixel::robertSetEdges (unsigned int edgePixel1, unsigned int edgePixel2, unsigned int edgePixel3)
{
P1 = edgePixel1;
P2 = edgePixel2;
P3 = edgePixel3;
}

unsigned int robertEdgePixel::getPixel1 ()
{
return P1;
}

unsigned int robertEdgePixel::getPixel2 ()
{
return P2;
}

unsigned int robertEdgePixel::getPixel3 ()
{
return P3;
}

int main ()
{

unsigned char robertM [2];
unsigned int robertTotalRows = 512;
unsigned int robertTotalColumn = 512;
unsigned int robertMaximumValue = 255;

int robertSizeVar = (3 * robertTotalRows * robertTotalColumn);

char *robertImg = new char [robertSizeVar];

ifstream robertExistingImg;
robertExistingImg.open ("robertImage.ppm", ios::in);

if (!robertExistingImg)
{
cout << " Error: Sorry. We are unable to open the selected image " << endl;
}


robertExistingImg >> robertM [0] >> robertM [1] >> robertTotalRows >> robertTotalColumn >> robertMaximumValue;

robertExistingImg.read(robertImg, robertSizeVar);

unsigned int robertValue1, robertValue2, robertValue3;


robertEdgePixel **robertEdgePixelVal;

robertEdgePixelVal = new robertEdgePixel* [robertTotalRows];
int T=0;


unsigned int robertPixelX, robertPixelY = 0;
unsigned int RE [3][3];
unsigned int RV [3][3];

// Robert Edge Horizontal Filter

   RE[0][0] = 1; RE[0][1] = 0; RE[0][2] = -1;
   RE[1][0] = 2; RE[1][1] = 0; RE[1][2] = -2;
   RE[2][0] = 1; RE[2][1] = 0; RE[2][2] = -1;

// Robert Edge Vertical Filter

   RV[0][0] = 1; RV[0][1] = 2; RV[0][2] = 1;
   RV[1][0] = 0; RV[1][1] = 0; RV[1][2] = 0;
   RV[2][0] = -1; RV[2][1] =-2; RV[2][2] = -1;

  
ofstream robertNewImageFile;
robertNewImageFile.open ("robertImage1.ppm", ios::out);
  
if (!robertNewImageFile)
{
cout << " Error: Sorry. We are unable to open the selected image " << endl;
}


robertNewImageFile.write(robertImg, robertSizeVar);

if (robertNewImageFile.fail())
{
cout << "We are unable to write your Image. Please Try Again " << endl;
}

robertNewImageFile.close();

delete [] robertImg;

return 0;
}

1 0 0 -1
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