The only thing I have to code is that inside of each function that I\'ll write a
ID: 3874754 • Letter: T
Question
The only thing I have to code is that inside of each function that I'll write after the project description.. And moreover, the code after that is main.cpp ( which is really long !!! and just use it as a reference) If you don't wanna read all of the main.cpp, and just doing 6 functions is fine !!
Anyone please help me to code those only 6 function to be work?
<Project01 Goals>
A fundamental software engineering skill is the design, implementation, and testing of a software component that may be integrated into a larger software product. In order to do this, the software component must conform to a previously agreed upon interface format. As part of this assignment, you will practice this skill by writing several functions that will be integrated into a larger software product provided by the instructor. Along the way you will review basic C++ programming skills
required for successful completion of CPE 212.
<Project01 Description>
For this project, you will complete the provided partial C++ program by implementing six functions that perform simple image processing operations on images stored as 10x10, two dimensional arrays of integers. The image processing operations are:
(1) Load Image
(2) Horizontal Flip
(3) Vertical Flip
(4) Transpose
(5) Rotate 90° Clockwise
(6) Rotate 90° Counter Clockwise
You must implement each of these operations as a C++ function. Your code for the six
functions above must appear in the file named project01.cpp in order to compile correctly.
Remember, spelling and capitalization count in Linux/C++.
The function main() has already been implemented for you to provide a common way for everyone to test their code. The function main() will scan a sample input file and perform the requested series of image processing operations by invoking your functions as needed. Prototypes for the six functions are already provided for you in main.cpp (do not modify main.cpp !!!). All program output is performed by the code in the main.cpp file – do not include any output statements in the file project01.cpp
The interfaces to each of these functions you must write are described in detail on
subsequent pages and in the prototypes listed within main.cpp
This is the only thing i need answer for Void prototype.Which i have below.
// Function Prototypes for the functions you must implement in project01.cpp
void LoadImage(const string imagefile, int image[MAXROWS][MAXCOLS])
{
}
void FlipHorizontal(int image[MAXROWS][MAXCOLS])
void FlipVertical(int image[MAXROWS][MAXCOLS])
void RotateCW(int image[MAXROWS][MAXCOLS])
void RotateCCW(int image[MAXROWS][MAXCOLS])
void Transpose(int image[MAXROWS][MAXCOLS])
Explanation / Answer
//run this program, i have made a main function which calls all the function
//you can change the code and check here
//also in loadImage you haven't specified what should happen
//and in many functions, the dimensions of the array will change, and it will be arr[col][row] not arr[row][col], so you need to take care of that.
#include<iostream>
#include<conio.h>
#include <iomanip>
using namespace std;
const int row = 5;
const int col = 6;
void fillArr(int arr[row][col]);
void printArr(int arr[row][col]);
void printArr2(int arr[col][row]);
void FlipHorizontal(int arr[row][col]);
void FlipVertical(int arr[row][col]);
void RotateCW(int arr[row][col]);
void RotateCCW(int arr[row][col]);
void Transpose(int arr[row][col]);
int main(){
int arr[row][col];
fillArr(arr);
printArr(arr);
FlipHorizontal(arr);
FlipVertical(arr);
RotateCW(arr);
RotateCCW(arr);
Transpose(arr);
}
void FlipHorizontal(int arr[row][col]){
int temp,i,j;
for(i=0 ; i<row ; i++){
for(j=0 ; j<(col+1)/2 ; j++){
temp = arr[i][j];
arr[i][j] = arr[i][col-j-1];
arr[i][col-j-1] = temp;
}
}
printArr(arr);
}
void FlipVertical(int arr[row][col]){
int temp,i,j;
for(i=0 ; i<col ; i++){
for(j=0 ; j<(row+1)/2 ; j++){
temp = arr[j][i];
arr[j][i] = arr[row-j-1][i];
arr[row-j-1][i] = temp;
}
}
printArr(arr);
}
void RotateCW(int arr[row][col]){
//during clockwise rotation, the resulting array will be of type arr[col][row]
int cwArr[col][row];
int i,j;
for(i=0 ; i<row ; i++){
for(j=0 ; j<col ; j++){
cwArr[j][row-1-i] = arr[i][j];
}
}
printArr2(cwArr);
}
void RotateCCW(int arr[row][col]){
int ccwArr[col][row];
int i,j;
for(i=0 ; i<row ; i++){
for(j=0 ; j<col ; j++){
ccwArr[col-j-1][i] = arr[i][j];
}
}
printArr2(ccwArr);
}
void Transpose(int arr[row][col]){
int transposeArr[col][row];
int i,j;
for(i=0 ; i<row ; i++){
for(j=0 ; j<col ; j++){
transposeArr[j][i] = arr[i][j];
}
}
printArr2(transposeArr);
}
//filling random values for testing
void fillArr(int arr[row][col]){
int i,j;
for(i=0 ; i<row ; i++){
for(j=0 ; j<col ; j++){
arr[i][j] = i+j;
}
}
}
//printing array
void printArr(int arr[row][col]){
int i,j;
for(i=0 ; i<row ; i++){
for(j=0 ; j<col ; j++){
cout<<" "<<setw(2)<<arr[i][j]<<" ";
}
cout<<endl;
}
cout<<endl;
}
void printArr2(int arr[col][row]){
int i,j;
for(i=0 ; i<col ; i++){
for(j=0 ; j<row ; j++){
cout<<" "<<setw(2)<<arr[i][j]<<" ";
}
cout<<endl;
}
cout<<endl;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.