<s> import sys <EOL> import urllib2 <EOL> import cv2 . cv as cv <EOL> src = <NUM_LIT:0> <EOL> image = <NUM_LIT:0> <EOL> dest = <NUM_LIT:0> <EOL> element_shape = cv . CV_SHAPE_RECT <EOL> def Opening ( pos ) : <EOL> element = cv . CreateStructuringElementEx ( pos * <NUM_LIT:2> + <NUM_LIT:1> , pos * <NUM_LIT:2> + <NUM_LIT:1> , pos , pos , element_shape ) <EOL> cv . Erode ( src , image , element , <NUM_LIT:1> ) <EOL> cv . Dilate ( image , dest , element , <NUM_LIT:1> ) <EOL> cv . ShowImage ( "<STR_LIT>" , dest ) <EOL> def Closing ( pos ) : <EOL> element = cv . CreateStructuringElementEx ( pos * <NUM_LIT:2> + <NUM_LIT:1> , pos * <NUM_LIT:2> + <NUM_LIT:1> , pos , pos , element_shape ) <EOL> cv . Dilate ( src , image , element , <NUM_LIT:1> ) <EOL> cv . Erode ( image , dest , element , <NUM_LIT:1> ) <EOL> cv . ShowImage ( "<STR_LIT>" , dest ) <EOL> def Erosion ( pos ) : <EOL> element = cv . CreateStructuringElementEx ( pos * <NUM_LIT:2> + <NUM_LIT:1> , pos * <NUM_LIT:2> + <NUM_LIT:1> , pos , pos , element_shape ) <EOL> cv . Erode ( src , dest , element , <NUM_LIT:1> ) <EOL> cv . ShowImage ( "<STR_LIT>" , dest ) <EOL> def Dilation ( pos ) : <EOL> element = cv . CreateStructuringElementEx ( pos * <NUM_LIT:2> + <NUM_LIT:1> , pos * <NUM_LIT:2> + <NUM_LIT:1> , pos , pos , element_shape ) <EOL> cv . Dilate ( src , dest , element , <NUM_LIT:1> ) <EOL> cv . ShowImage ( "<STR_LIT>" , dest ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> if len ( sys . argv ) > <NUM_LIT:1> : <EOL> src = cv . LoadImage ( sys . argv [ <NUM_LIT:1> ] , cv . CV_LOAD_IMAGE_COLOR ) <EOL> else : <EOL> url = '<STR_LIT>' <EOL> filedata = urllib2 . urlopen ( url ) . read ( ) <EOL> imagefiledata = cv . CreateMatHeader ( <NUM_LIT:1> , len ( filedata ) , cv . CV_8UC1 ) <EOL> cv . SetData ( imagefiledata , filedata , len ( filedata ) ) <EOL> src = cv . DecodeImage ( imagefiledata , cv . CV_LOAD_IMAGE_COLOR ) <EOL> image = cv . CloneImage ( src ) <EOL> dest = cv . CloneImage ( src ) <EOL> cv . NamedWindow ( "<STR_LIT>" , <NUM_LIT:1> ) <EOL> cv . NamedWindow ( "<STR_LIT>" , <NUM_LIT:1> ) <EOL> cv . ShowImage ( "<STR_LIT>" , src ) <EOL> cv . ShowImage ( "<STR_LIT>" , src ) <EOL> cv . CreateTrackbar ( "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT:0> , <NUM_LIT:10> , Opening ) <EOL> cv . CreateTrackbar ( "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT:0> , <NUM_LIT:10> , Closing ) <EOL> cv . CreateTrackbar ( "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT:0> , <NUM_LIT:10> , Dilation ) <EOL> cv . CreateTrackbar ( "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT:0> , <NUM_LIT:10> , Erosion ) <EOL> cv . WaitKey ( <NUM_LIT:0> ) <EOL> cv . DestroyWindow ( "<STR_LIT>" ) <EOL> cv . DestroyWindow ( "<STR_LIT>" ) </s>
