Home > Software engineering >  Histogram specification
Histogram specification

Time:09-24

Small white one, just began learning digital image processing, the current course just about histogram regulation, homework problems encountered in the process, the requirement is matched to the gaussian distribution histogram, the results are as follows,


I am a direct reference to textbook writing compiled code, please god help small white
The function I=matchgaussian (I, max1)

Subplot (221);
Imshow (I);
Subplot (222);
The histogram (I);

[the row, col]=size (I);
Pixels=row * col;
M=[pixels, 1);
Z=normrnd (128, 35, m);
Z=round (z);
[row1, col1]=size (z);
Hist_gaussian=zeros (max1, 1);
For I=1: row1
If (1 & lt; Z=(I, 1) & amp; & Z (I, 1) & lt;
=256)Hist_gaussian (z (I, 1), 1)=hist_gaussian (z (I, 1), 1) + 1;
End
End

Lut1=I + 1;
Hist_org=makeHistogram (row, col, lut1 max1);
Map_org=mapping (hist_org, pixels, max1);
Map_gaussian=mapping (hist_gaussian, pixels, max1);
Posibi_org=hist_org/pixels;
[map_new posibi_new]=GML (posibi_org, map_org, map_gaussian max1);

For I=1: row
For j=1: col
If (map_new (I (I, j) + 1) & lt; 20)
I (I, j)=(I (I, j) + 10) * 4;
The else
I (I, j)=map_new (I (I, j) + 1);

End
End
End


H=[1, 2, 1, 2,4,2, 1, 2, 1]/16;
I=filter2 (h, I);


I=uint8 (fix (I));

Subplot (223);
Imshow (I);
Subplot (224);
The histogram (I);

Set of mapping
Function [map_new posibi_new]=GML (posibi_org, map_org, map_spec max1)

A=zeros (max1, 1);
L=0;
Posibi_new=zeros (max1, 1);
Map_new=zeros (max1, 1);

For I=1: max1

If (abs (map_spec e (I) - 1-3) & gt; 0)
A=a + map_spec (I);
[min1 posi_new]=min (abs (a - map_org));
A=zeros (max1, 1);

If (l==0)
Map_new (posi_new)=I - 1;
Posibi_new (I)=posibi_org (posi_new);
Posi_old=posi_new;
L=l + 1;
The else
If (abs (posi_new - posi_old) & gt;
=1)For j=posi_old + 1: posi_new
Map_new (j)=I - 1;
Posibi_new (I)=posibi_new + posibi_org (I) (j);
End
Posi_old=posi_new;
The else
;
End
End


End

End
If you can solve, thank you very much,

CodePudding user response:

Forgot to say the problem
After (1) set of mapping a large number of 0 grayscale pixels
2. There is a like a histogram is chewed, very not good-looking

CodePudding user response:

Baidu search relevant keywords,
Image processing based http://www.codeproject.com/Articles/781213/Fundamentals-of-Image-Processing-behind-the-scenes
  • Related