File tree Expand file tree Collapse file tree 1 file changed +6
-11
lines changed Expand file tree Collapse file tree 1 file changed +6
-11
lines changed Original file line number Diff line number Diff line change 1
- function [ out_image ] = quantization( input_image ,layers )
2
- % UNTITLED2 Summary of this function goes here
3
- % Detailed explanation goes here
4
- gray_scale= 255 ;
5
- slide_size= gray_scale / layers ;
1
+ function [ out_image ] = quantization( input_image ,levels ,scale )
2
+ % quantization Uniform scalar quantization
3
+ if nargin == 2 , scale= 256 ; end
4
+ cluster_size= scale / levels ;
6
5
7
6
out_image= zeros(size(input_image ));
8
7
9
8
for i = 1 : size(input_image ,1 )
10
9
for j = 1 : size(input_image ,2 )
11
- aux= 0 ;
12
- while (aux < input_image(i ,j ))
13
- aux = aux + slide_size ;
14
- end
15
- out_image(i ,j )=round(aux - slide_size / 2 );
10
+ out_image(i ,j ) = round((input_image(i ,j )/cluster_size - cluster_size )/2 );
16
11
end
17
12
end
18
13
19
-
14
+ out_image = uint8( out_image );
20
15
end
21
16
You can’t perform that action at this time.
0 commit comments