|
可参考链接:http://blog.csdn.net/carson2005/article/details/9502053
http://www.cnblogs.com/Imageshop/p/3810402.html
MATLAB retinex:http://halcom.cn/forum.php?mod=v ... ge=1&extra=#pid1127
- read_image (Image, 'C:/Users/ysw/Desktop/视频讲解/图库/Tulips.jpg')
- count_channels(Image, Channels)
- if(Channels==1)
- return()
- else
- decompose3(Image,R,G,B)
- c :=500
- get_image_size(R,Width, Height)
- tuple_gen_sequence(0, Width*Height-1, 1, Sequence)
- tuple_mod(Sequence,Width, CF)
- tuple_div(Sequence,Width,RF)
- Fnok := exp( - ( (RF-Height/2)*(RF-Height/2)+ (CF-Width/2)*(CF-Width/2) )*1.0/c/c )
- K:=1.0/sum(Fnok)
- F := K*Fnok
-
- convert_image_type(R,IR,'real')
- convert_image_type(G,IG,'real')
- convert_image_type(B,IB,'real')
-
- gen_image_const(Filters, 'real', Width, Height)
- set_grayval(Filters, RF,CF,F)
- *fft_generic(Filters, FF,'to_freq', -1, 'sqrt', 'dc_center', 'complex')
- fft_image(Filters,FF)
-
- fft_generic(IR, IFR, 'to_freq', -1, 'sqrt', 'dc_center', 'complex')
- mult_image(IFR,FF,IFR,1.0,0)
- fft_generic(IFR,IFR,'from_freq',1,'sqrt','dc_center','real')
-
- fft_generic(IG, IFG, 'to_freq', -1, 'sqrt', 'dc_center', 'complex')
- mult_image(IFG,FF,IFG,1.0,0)
- fft_generic(IFG,IFG,'from_freq',1,'sqrt','dc_center','real')
-
- fft_generic(IB, IFB, 'to_freq', -1, 'sqrt', 'dc_center', 'complex')
- mult_image(IFB,FF,IFB,1.0,0)
- fft_generic(IFB,IFB,'from_freq',1,'sqrt','dc_center','real')
-
- log_image(IR, LIR, 10)
- log_image(IG, LIG, 10)
- log_image(IB, LIB, 10)
-
- log_image(IFR, LIFR, 10)
- log_image(IFG, LIFG, 10)
- log_image(IFB, LIFB, 10)
-
- sub_image(LIR, LIFR, RR, 1.0, 0)
- sub_image(LIG, LIFG, GG, 1.0, 0)
- sub_image(LIB, LIFB, BB, 1.0, 0)
-
- scale_image_max(RR,RR)
- scale_image_max(GG,GG)
- scale_image_max(BB,BB)
-
- compose3(RR,GG,BB,ImageRetinex)
- endif
复制代码
|
|