The image is the filtered image pixels are unimportant dyed background color, so that the important part is highlighted. Now given a monochrome image, the gray value is located in claim you all pixels within a designated color range are replaced with one specified color.
Input formats:
An input image is given in the first line resolution, i.e. two positive integers M and N ( 0), is to be additionally filtered gray value interval endpoints A and B ( 0), and the gradation values specified replacement . Subsequently M rows, each row gives the N gradation values of pixels, separated by a space therebetween. All the gradation values are within [0, 255] interval.
Output formats:
An output filtered image as required. I.e., the output of M rows, each row of N pixel grayscale values, each representing three gradation values (e.g., to be displayed as black 000
), separated by a space therebetween. Line from beginning to end may not have the extra space.
Sample input:
3 5 100 150 0
3 189 254 101 119
150 233 151 99 100
88 123 149 0 255
Sample output:
003 189 254 000 000 000 233 151 099 000 088 000 000 000 255
#include <iostream> using namespace std; int main(){ int M,N,A,B,T,tmp; cin>>M>>N>>A>>B>>T; for(int i=0;i<M;i++){ for(int j=0;j<N;j++){ scanf("%d",&tmp); if(tmp>=A&&tmp<=B) printf("%03d",T); else printf("%03d",tmp); if(j!=N-1) printf(" "); else printf("\n"); } } system("pause"); return 0; }
cin >> cout << not be used, a large amount of data, easy timeout