电脑中无意everything出这个pro来,简单修改完善了下共享出来。
PRO kill_canny_app, event
shmunmap, 'rose_shmmap'
END
PRO CannyApp_event, event
centered = 0
case widget_info(event.id, /uname) of
"HIGHv": goto, FilterIt
"LOWv": goto, FilterIt
"SIGMAv": goto, FilterIt
"BtnQuit": goto, ExitFilterApp
endcase
FilterIt:
sliderH_ID = widget_info(event.top, find_by_uname = "HIGHv")
widget_control, sliderH_ID, get_value = HighValue ; <-- in percentage
sliderL_ID = widget_info(event.top, find_by_uname = "LOWv")
widget_control, sliderL_ID, get_value = LowValue ; <-- in percentage
sliderS_ID = widget_info(event.top, find_by_uname = "SIGMAv")
widget_control, sliderS_ID, get_value = SigmaValue ; <-- in percentage
HighValue = HighValue * 0.01
LowValue = LowValue * 0.01
SigmaValue = SigmaValue * 0.01
wDraw2_ID = widget_info(event.top, find_by_uname = "RoseEdges")
widget_control, wDraw2_ID, get_value = ID_grWindow2
rose_image = shmvar('rose_shmmap')
;_____Plot the edges of the image:_____
wset, ID_grWindow2
rose_xsize = (size(rose_image, /dimensions))[1]
rose_ysize = (size(rose_image, /dimensions))[2]
red_rose = reform(rose_image[0, *, *], rose_xsize, rose_ysize)
green_rose = reform(rose_image[0, *, *], rose_xsize, rose_ysize)
blue_rose = reform(rose_image[0, *, *], rose_xsize, rose_ysize)
red_edge = CANNY(red_rose, HIGH = HighValue, LOW = LowValue, SIGMA = SigmaValue)
green_edge = CANNY(green_rose, HIGH = HighValue, LOW = LowValue, SIGMA = SigmaValue)
blue_edge = CANNY(blue_rose, HIGH = HighValue, LOW = LowValue, SIGMA = SigmaValue)
RGB_edge = bindgen(3, 227, 149)
RGB_edge[0, *, *] = red_edge * 255
RGB_edge[1, *, *] = green_edge * 255
RGB_edge[2, *, *] = blue_edge * 255
TV, RGB_edge[0,*,*],CHANNEL=1
TV, RGB_edge[1,*,*],CHANNEL=2
TV, RGB_edge[2,*,*],CHANNEL=3
goto, AllDone
ExitFilterApp:
shmunmap, 'rose_shmmap'
widget_control, event.top, /destroy
return
AllDone:
END
PRO CannyApp
COMPILE_OPT IDL2
;_____Create the unfiltered image:_____
rose_path = "C:Program FilesITTIDLIDL80examplesdatarose.jpg"
if file_test(rose_path) ne 1 then begin
tmp = dialog_message('file not exist'+String(13b)+$
rose_path,/error)
return
endif
rose_image = read_image(rose_path)
;______________________________________
;_____Set up shared memory (so event handler can have image):_____
shmmap, 'rose_shmmap', /BYTE, size(rose_image, /dimensions)
shm_var = shmvar('rose_shmmap')
shm_var[*] = rose_image
;_________________________________________________________________
;_____Create the edge-detected image:_____
rose_xsize = (size(rose_image, /dimensions))[1]
rose_ysize = (size(rose_image, /dimensions))[2]
red_rose = reform(rose_image[0, *, *], rose_xsize, rose_ysize)
green_rose = reform(rose_image[0, *, *], rose_xsize, rose_ysize)
blue_rose = reform(rose_image[0, *, *], rose_xsize, rose_ysize)
red_edge = CANNY(red_rose)
green_edge = CANNY(green_rose)
blue_edge = CANNY(blue_rose)
RGB_edge = bindgen(3, 227, 149)
RGB_edge[0, *, *] = red_edge * 255
RGB_edge[1, *, *] = green_edge * 255
RGB_edge[2, *, *] = blue_edge * 255
;____________________________________
;_____Build the widgets:_____
wTLB=WIDGET_BASE(/ROW)
wControls = widget_base(wTLB, /column)
wLeft = WIDGET_BASE(wTLB,/COLUMN)
wRight = WIDGET_BASE(wTLB,/COLUMN)
wBase1 = WIDGET_BASE(wLeft,/COLUMN)
wBase2 = WIDGET_BASE(wRight,/COLUMN)
wText1a = WIDGET_LABEL(wBase1,VALUE="Original Rose")
wDraw1 = WIDGET_DRAW(wBase1,XSIZE = rose_xsize, YSIZE = rose_ysize)
wText2 = WIDGET_LABEL(wBase2,VALUE="Rose's edges")
wDraw2 = WIDGET_DRAW(wBase2,XSIZE = rose_xsize, YSIZE = rose_ysize, uname = "RoseEdges")
;_____Controllers:_____
wSliderH = widget_slider(wBase1, title = "High Value (% of maximum pixel value):", maximum = 100, $
minimum = 0, value = 80, uname = "HIGHv")
wSliderL = widget_slider(wBase1, title = "Low Value (% of High Value):", maximum = 100, $
minimum = 0, value = 40, uname = "LOWv")
wSliderS = widget_slider(wBase1, title = "Sigma %", maximum = 100, $
minimum = 0, value = 60, uname = "SIGMAv")
wButtonQuit = widget_button(wBase1, value = "Quit Edge App", uname = "BtnQuit")
;____________________________
WIDGET_CONTROL,wTLB,/REALIZE
;____________________Draw the images:____________________
widget_control, wDraw1, GET_VALUE = window1ID
widget_control, wDraw2, GET_VALUE = window2ID
;_____Plot the original image:_____
wset, window1ID
reconstructed_rose = bindgen(227, 149, 3)
reconstructed_rose[*,*,0] = red_rose
reconstructed_rose[*,*,1] = green_rose
reconstructed_rose[*,*,2] = blue_rose
TV,rose_image[0,*,*],CHANNEL=1
TV,rose_image[1,*,*],CHANNEL=2
TV,rose_image[2,*,*],CHANNEL=3
;_____Plot the edges of the image:_____
wset, window2ID
TV, RGB_edge[0,*,*],CHANNEL=1
TV, RGB_edge[1,*,*],CHANNEL=2
TV, RGB_edge[2,*,*],CHANNEL=3
;________________________________________________________
XMANAGER,'CannyApp',wTLB, cleanup = "kill_canny_app"
END
;---
转载本文请联系原作者获取授权,同时请注明本文来自董彦卿科学网博客。 链接地址: https://blog.sciencenet.cn/blog-344887-389409.html
上一篇:
ENVI for ArcGIS? Server 下一篇:
grib气象数据IDL 读取