CMP2090M? ?Object? ?Oriented??Programming? ?Assignment Report Introduction?(Your? ?understanding? ?of? ?the? ?aims? ?of??the? ?problem.

)The aim of this assignment was to produce a program writtenin the C++ language that was capable of un-shuffling a shuffled image, theimage being the old University of Lincoln logo. This was to be achieved withthe implementation of the “Nearest Neighbour Search” while using goodobject-oriented principles and practice. The image input would be a text filecontaining the 0 – 255 representing a greyscale colour. The output of thefinished unshuffled logo was to be in a PGM format with the ability to view theimage using an online converter to JPG. The assignment also includes a part toconvert a noisy version of the image that requires translating into a binaryimage. This assignment is broken down into the two parts the first objective isto unshuffle the 512 by 512 logo image which is broken down into blocks of 32by 32. Then there is the second part which involves an unshuffled noisy imageof the logo.

We Will Write a Custom Essay Specifically
For You For Only $13.90/page!

order now

This second objective involves cleaning the noisy image by using athreshold. Then all the blocks in the cleaned image will need to be comparedagainst all the blocks in the shuffled image. For a complete new unshuffledimage of the logo a new matrix will then need to be created.

This is for theblock from the shuffled image to go to its correct location from the cleanedblock into the new image created.      Methods?(Design? ?(e.g.? ?the? ?OO? ?principles? ?used,? ?the??interface? ?of? ?your? ?library,? ?that  is,? ?the? ?.h? ?file? ?with??Class? ?definitions)? ?and? ?Pseudo-Code.)The project contains three classes: main.cpp, Matrix.

cppand BinaryImage.cpp with two .h files Matrix.h and BinaryImage.h. Main ClassThe project’s Main class is the entry for program to startat, it contains: ·        Themethods for reading in the txt files the shuffled image and the noisy image. ·        TheNearest Neighbour Search algorithm.

·        TheSummed Squared Difference ·        Andthe method for writing out the complete unshuffled image to PGM format     Matrix ClassThe project’s Matrix class contains methods that aredesigned to handle the data as the class has been designed to hold the data ofthe images. This class has been created to make the handling of the dataeasier. As images are two dimensional matrices the class treats one-dimensionalarrays as two-dimensional arrays. The class also has a header file, as it usestemplates the class declaration and member functions need to be in the sameheader file this allows them to be linked together correctly.Within the specifications of the assignment it stated thematrix class should contain:·        Constructors·        Adestructor ·        Operatoroverloads ·        MatrixoperationsConstructors The program uses three different constructors in the matrixclass, a blank constructor, a constructor that takes two integers and a doublevalue and another constructor that takes two constructors that takes twointegers and a double that points to an array. Constructor 1The blank constructor has been made so that it can used forcreating placeholder matrixes. Constructor 2The constructor takes M, N and an input data value, then willset the inputted M and N to the M and N of the object then allocate memory todata and set every location in that memory to the input value.

M = input row N = input column Data = new double M * N   For (i = 0; i < M * N; i++) {datai = input_datai }Constructor 3The copy constructor willset the matrix its running off, equal to the inputted matrix while copying thevalues over. DestructorThe destructor in the program is used when an object goesout of scope. This code is used to make sure that a large amount of memoryisn't used. It does this by deleting the data that the matric class has usedand created.    Operator Overload - The operator overload for the - is declared virtualso that it can be overridden for later so that they will be able to return amatrix.

The operator will take one argument a constantMatrix reference. Then the method will declare an array of matrix temp andallocate it M * N of allotted memory and will then go through every element ofeach matrix and will subtraction. = new double temp.

M*temp.N for (i = 0; i < temp.M * temp.N; i++){temp.datai = datai - datai}return temp Operator Overload =The purpose of the operator overload for the = isto set the value of one matrix to another matrix. The operator achieves this bydeleting the data of the first matrix. Then it will set the matrix M and N ofthe first matrix to the second matrix's M and N.

It then allocates the memorysized M * N for data and sets each of its values in data equal to the values inthe second matrix’s data. Once this has been done the operator will then go onto return the pointer of the matrix. Operator Overload()The () operator overload takes two ints i and j coordinatesand then returns a value in that position.

It does this by returning a valuefrom theData using i * N + j formula. Sum of Squared Difference     The sum of squared difference method works by taking two blocks then subtractsone from the other one and then returns the sum of the squared values from the subtraction.The method returns a score of the Matrix in the form of a double