Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Histogram = MakeHistogramRGB(InputImage, n)
- [height width] = size(InputImage);
- Histogram = zeros(1, 255);
- for i = 1 : height
- for j = 1 : width
- Start = 0;
- End = 255 / n;
- for k = 1 : n
- for l = 1 : 3
- tmp = InputImage(i, j) - 1;
- if (tmp >= Start & tmp <= End)
- avg = ((Start + End) / 2);
- uint8(avg);
- Histogram(avg) = Histogram(avg) + 1;
- end
- Start = Start + End;
- End = End + End;
- end
- end
- end
- printf("%d\n",double(i/height)*100);
- end
- endfunction
- function Histogram = MakeHistogramGray(InputImage, n)
- [height width] = size(InputImage);
- Histogram = zeros(1, 255);
- for i = 1 : height
- for j = 1 : width
- Start = 0;
- End = 255 / n;
- for k = 1 : n
- tmp = InputImage(i, j) - 1;
- if (tmp >= Start & tmp <= End)
- avg = ((Start + End) / 2);
- uint8(avg);
- Histogram(avg) = Histogram(avg) + 1;
- end
- Start = Start + End;
- End = End + End;
- end
- end
- printf("%d\n",double(i/height)*100);
- end
- endfunction
- global IPD_PATH;
- RGB = ReadImage(IPD_PATH + 'demos\teaset.png');
- Gray = RGB2Gray(RGB);
- scf(1); ShowImage(Gray, 'RGB');
- hist=MakeHistogramGray(Gray,100);
- scf(2);plot(hist);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement