-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImage.cpp
More file actions
71 lines (59 loc) · 1.58 KB
/
Copy pathImage.cpp
File metadata and controls
71 lines (59 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "Image.h"
#include <stdlib.h>
#include "functions.h"
using namespace std;
Image::Image(){
rows = 0;
cols = 0;
depth = 0;
pixelVal = NULL;
pixelVal3 = NULL;
}
Image::Image(int numRows, int numCols, int Ndepth){
rows = numRows;
cols = numCols;
depth = Ndepth;
pixelVal = new int*[rows];
pixelVal3 = new int**[rows];
for (int i = 0; i < rows; i++) {
pixelVal[i] = new int[cols];
for (int j = 0; j < cols; j++) {
pixelVal[i][j] = 0;
}
}
for(int i = 0; i < rows; i++){
pixelVal3[i] = new int*[cols];
for(int j = 0; j < cols; j++){
pixelVal3[i][j] = new int[depth];
for(int k = 0; k < depth; k++){
pixelVal3[i][j][k] = 0;
}
}
}
}
Image:: ~Image(){
for(int i = 0; i < rows; i++)
delete pixelVal[i];
for(int i = 0; i < rows; i++){
for(int j = 0; j < cols; j++){
delete pixelVal3[i][j];
}delete pixelVal3[i];
}
rows = 0;
cols = 0;
depth = 0;
delete pixelVal;
delete pixelVal3;
}
int Image::getPixelVal(int row, int col){
return pixelVal[row][col];
}
void Image::setPixelVal(int row, int col, int value){
pixelVal[row][col] = value;
}
int Image::getPixelVal3(int row, int col, int depth){
return pixelVal3[row][col][depth];
}
void Image::setPixelVal3(int row, int col, int depth, int value){
pixelVal3[row][col][depth] = value;
}