C++ Highlighting Image One way to highlight objects in an image is to make all p
ID: 3760257 • Letter: C
Question
C++ Highlighting Image
One way to highlight objects in an image is to make all pixels below a threshold (T1) 0, and all pixels about a threshold (T2) 255. Write a program to input T1 and T2 and highlight the image.
int main() {
int width, height;
int inImage[MAXWIDTH][MAXHEIGHT];
int outImage_1[MAXWIDTH][MAXHEIGHT];
readImage(inImage, width, height);
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
if(inImage[i][j] < 170){
outImage_1[i][j] = 255;
}
else{
outImage_1[i][j] = 0;
}
}
}
writeImage(outImage_1, width, height);
return 0;
}
This is what I have so far but it doesn't work.I just need to fix the main. If anyone has any other ideas, please help.
Explanation / Answer
int main() {
int width, height;
int inImage[MAXWIDTH][MAXHEIGHT];
int outImage_1[MAXWIDTH][MAXHEIGHT];
readImage(inImage, width, height);
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
if(inImage[i][j] < 170){
outImage_1[i][j] = 0; //below is zero not 255
}
else{
outImage_1[i][j] = 255; //and above threshold is 255 not zero
}
}
}
writeImage(outImage_1, width, height);
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.