Part A-1: Run the following templates and determine their tasks. In this problem set, you will apply different template operations and determine proper initial settings. Use the following notations from the textbook to specify initial network settings. If a static binary image P is given then initial conditions should be specified as Input: U(t) = P / arbitrary / value = [-1;1]; e.g. U (t) = P Initial state: X(0) = 0 / P / arbitrary / value = [-1; 1] e.g. X (0) = arbitrary Boundary condition: fixed value = [-1; 1] / zero-flux / periodic e.g. zeroflux All templates and images can be obtained from the directory “\Temlib” and “\Piclib” respectively from CANDY. Run the following templates on the simulator and paste your outputs on the attached blank solution forms. Specify proper initial settings (this is the trickiest part! – try several options). What task is performed by each template? Number Template 1. EDGE Image (P) Output CONC2.BMP Network Settings Input - U: Picture Initial State - X(0): Arbitrary Boundary: Zero-flux, Gray, Periodic Task: Candy running 1 tau, with 0,1 step. If I change tau smaller then 1 (0,5), then I get This: The reason is that, it can’t running completely. 1 Number Template 2. DIFFUS Image (P) Output MADONNA.BMP Network Settings (select a specific running time) Input - U: Gray background Initial State - X(0): Picture Boundary: Fixed 0 Tau=1 Task: This template made a smoother picture. The result of Tau=5: Number Template 3. EROSION Image (P) Output FIGREC.BMP Network Settings Input - U: Picture Initial State - X(0): Arbitrary Boundary: Fixed 0 Tau=10 2 Here the erosion is depend from tau, such as Tau=2, we can find gray squares: When the state value=5, then Number Template 4. SHADOW Image (P) Output HOLLOW.BMP Network Settings (set a proper running time!) - Running time: 150 Input - U: Picture Initial State - X(0): Value: 1 Boundary: 0 When the Initial State is arbitrary, then nothing happen. Otherwise a shadow to left. Number Template Image (P) Output 3 5. GRADIENT AVERGRA1.BMP Network Settings Input - U: Picture Initial State - X(0): Arbitrary Boundary: Zero-flux It’s a simple gradient search. 4 Part A-2: Design simple zero-input templates Design 2 zero-input (autonomous) class CNN templates - C(A, 0, z) - to produce the following 2 outputs from the image on the left (AVERGRA2.BMP). (see textbook pp. 28, Eq. 2.40 for the definition of class C(A, 0, z) (autonomous) CNN ). Hint: Zero-input means that values of the B template should be zero. Output should be a binary image and this determines condition for A00. The two templates are same except one value. Task 1 – producing output 1 Network settings Input Non definied Initial State The Picture Boundary Condition Fixed 0 input output 1 Your first template: 0 0 0 A= 0 2 0 0 0 0 B= 0 0 0 0 0 0 0 0 0 z= -0,25 Task 2 – producing output 2 Network settings Input Non definied Initial State The Picture Boundary Condition Fixed 0 input output 2 Your second template: 0 0 0 A= 0 2 0 0 0 0 B= 0 0 0 0 0 0 0 0 0 z= 0,5 Part A-3: Design templates solving the following operations Task 1 – producing output 1: Given the two images P1 (LIFE_1.BMP) and P2 (CONC1.BMP), find a 5 template that produces the output 1. Verify your answer using the simulator and specify template and proper initial settings. input1 – P1 input2 – P2 Your template to obtain output 1 0 0 0 A= 0 1 0 B= 0 0 0 output 1 0 0 0 0 1 0 0 0 0 z= 1 Network settings Input Initial State Boundary Condition P1 P2 Zero-flux Task performed by template is: I thin that this is a simple addition (or UNION). So, if one of them is black, then I should make black. If white, then I make white. So I need only the middle pixels. Task 2 – producing output 2: Given the two images P1 (CHINEESE.BMP) and P2 (CONC1.BMP), find a template that produces the output 2. input1 – P1 input2 – P2 Your template to obtain output 2 0 0 0 A= 0 2 0 B= 0 0 0 output 2 0 0 0 0 1 0 0 0 0 z= -1 Network settings Input P1 Initial State P2 Boundary Condition 0 6 Name: Midterm Project – Part B Issued on: March 16, 2006 – Due date: March 31, 2006 The Midterm Project has 2 parts (Part A and Part B). This document contains Part B. There are several different ways to run CNN templates on the CNN simulator “CANDY”. “Template Runner” is the easiest one among them. All of the following problems can be run on the “template runner”. Images can be found in directory \PicLib of Candy or downloadable from the course web page. Part B Design CNN templates to implement the following five (5) given tasks. You must document your design procedure to receive credit, which should include the following: Based on the task, determine the template format, e.g. which are the zero and non-zero template elements, what symmetries should there be, or what elements should be identical? Determine the settings of the network (input, initial state, boundary) and also the simulation parameters (simulation time, time step, sampling) Determine the set of inequalities on the template elements required by the task. Find the solution of the system of inequalities. Test your template with the Candy simulation system. Optimize your template (if applicable) with the TEMMASTER program. Task 1: Design a single template which implements a simple morph transition. Example: herring.bmp (P1) snapshot 1 snapshot 2 snapshot 3 median.bmp (P2) Task: Template implements a simple morph transition between two images. Given: two grayscale images, P1 and P2 Input: U(t) = P2 Initial State: X(0) = P1 Boundary Conditions: zeroflux Output: Y(t) = a transition from P1 to P2, Y(∞) = P2 (grayscale image) 7 Hint: Terms “image morph” or “image morphing” define an image processing technique as the movement (transition) from one image into another one. It is typically used in animation tools and most common examples can be seen in music videos. There are lots of examples of one face morphing into another face (you can create humorous examples and show them to your friends). This can be implemented as an uncoupled template and morphing will take place during the CNN transient. You should specify an “Output Sampling” value in the simulator to be able to see this transient. In the example shown above snapshots are the consecutive steps of this transient. Definition of uncoupled template can be found in the textbook (paragraph 2.2.5, Fig. 2.24). Also you do not need coupling among the input cells either. This means you should specify only two template values, namely, a00 and b00. Keep in mind that the input is grayscale and also the output (steady state of the CNN) should remain in the grayscale region [-1, 1]. This means if you sketch the DP plot it cannot have stable solutions in the saturated regions. Also avoid semi-stable solution in the grayscale region otherwise the final steady state won’t be P2. Simulator: to specify two images you should set the TemRunner input and state parameters to Picture and Picture2 before starting the template execution. Task 2: Example: Deleting Short Vertical lines. Input (P1) Output (P2) LINCUT7V.bmp Task: Design a 3x1 template which deletes vertical lines of length 1, 2, or 3 pixels in black and white images. Longer vertical lines should have one and only one pixel removed from both ends. Given: a binary image, P1 Output: Y(∞) = P2 (binary image) showing only long vertical lines. Hint: Check template library for a similar template. Description of templates can be found at web page: http://lab.analogic.sztaki.hu/Candy/csl.html. First, try to erase 1- and 2-pixel long vertical lines (uncoupled template). To erase even 3-pixel long vertical lines you might need the propagating property of the A template. A similar template is DELVERT1.tem (this is an example for uncoupled template). But this template erases vertical lines even longer lines than 3 pixels. You want to keep them except up to 3-pixel long ones. (Do not just copy template elements from DELVERT1.tem to accomplish your task.) First, to erase 1- and 2- pixel long vertical lines you need to keep points that belong lines at least 3-pixel long ones. This will give you values for the B template, b-1,0 and b1,0. This will be an uncoupled template. Now you want to erase even 3-pixel long lines. Therefore you must modify the A template values a-1,0 and a1,0. Other template values (B, z) might remain the same. 8 Task 3: Design template(s) locating the main groups of points. Example: Input (P1) Output (P2) PointSet.bmp (course web page) Task: Given an image (P1) similar to the one shown above, locate the main groups of points (similar to output image P2). Given: a binary image, P1 Output: Y(∞) = P2 (binary image) showing main groups of points Hint: To solve this problem non-local information is needed. You have to use the propagating property of the A template. Where the average pixel number is large enough, there is a group. Apply blurring, then some kind of thresholding method. If you cannot solve this task with a single template you can run two templates, the second one should be applied on the sub-result of the first template. See templates e.g. DIFFUS.tem, AVERAGE.tem, and THRES.tem in directory \Temlib of Candy. Do not forget to specify the proper running times. Task 4: Design propagating type template which deletes unclosed lines. Example: Input (P1) ClosedLines.bmp (course web page) Output (P2) Task: Given a binary image similar to the one shown above, design a propagating type template that repeatedly deletes the last pixels of a line. In this way, at the end of the transient, the unclosed lines (which have line ends) will be deleted, but the closed loops will remain unchanged. We assume that there are non-crossing single pixel wide lines on a black-and-white image. Given: a binary image, P1 (non-crossing, single pixel wide lines) Output: Y(∞) = P2 (binary image) showing only closed loops. Hint: You need to use the propagating property of the A template. Check the template library for a similar template. Web page: http://lab.analogic.sztaki.hu/Candy/csl.html. Do not forget to specify the proper running time (does it depends on the image content?). Template values: a0,0; a-1,0; a0,-1; a0,1 and a1,0; b0,0 and z. Task 5: Local Logic Template design. 9 Design a template which can extract the (a), (b), and (c) local patterns, i.e. the output will be black if, and only if, the local input neighborhood is one of these patterns. The dash means “don’t care.” (a) (b) (c) Example: Input (P1) – LocalLogic.bmp (course web page) Output (P2) Given: a binary image, P1 Output: Y(∞) = P2 (binary image) showing only centers of matched patterns. Hint: Optimize your template with the TEMMASTER program. This will be an uncoupled template. 10 Task 1: The simpliest way to change the picture1, with picture2 when we change only the centeral pixel in B template, and I shouldn’t use feedback mechanism in template A. When I search a better algorithm, I found the morph template, which is same as mine. Template: 0 0 0 0 0 0 A= 0 0 0 B= 0 1 0 z= 0 0 0 0 0 0 0 Network settings Input Picture2 Initial State Picture1 Boundary Condition Fixed 0 Simulator settings Running time 4,6 Time step 0,01 Output sampling 1 LÉGYSZI AZ ÁTMENETET CSINÁLD MEG, HOGY NE LEGYEN FELTŰNŐ!!! I make some snapshot with mine template (running 4,3, with step 0,1): Tau: 0 1 2 3 4,6 Target We can see that, mine template is good. I tried to optimize the Temmaster, but I get a very bad A template, which was not efficient. 11 Task 2: The task is to design a template, which deletes the vertical lines of length 1-3 pixels, and one pixel removed from both ends, where the line is longer than 3 pixel. My algorithm is depend from bias. If I modified even with small value of the bias, than I can’t get the proper result, or worse. The ideal bias value is -2, which came from the erosion template. We want to delete vertical line pixels, that’s why the not zero values of the A and B matrix have a vertical structure. INNEN KISZEDTEM NÉMI RÁM SPECIFIKUS RÉSZT. The result was good, but I get a tip, and I tried to calc with center: Template: 0 1 0 0 1 0 A= 0 1 0 B= 0 1 0 z= 0 1 0 0 1 0 Network settings Input Picture Initial State Arbitrary Boundary Condition Fixed 0 -2 Simulator settings Running time 2 Time step 0,1 Output sampling 1 So this is better, because the running time is half, so its, the good: 12 Task 3: In First time try to make step-by-step the hint with random tau. The Candy is inbuilt DIFFUS template was realy useful, but the AVERAGE result was small. The TRESHOLD was very strange, but I saw that, in small tau was near the output. So I decided that, I tried to change the bias of this template (original was -0.4). I tried many bias up to 0.5 (with tau=3): Second, I tried to tune the good settings, first the Diffus: Template: 0,1 0,15 0,1 A = 0,15 0 0,15 0,1 0,15 0,1 Network settings Input Undef Initial State Picture Boundary Condition 0 B= 0 0 0 0 0 0 0 0 0 z= 0 Simulator settings Running time 16 Time step 0,1 Output sampling 1 13 Template: 0 A= 0 0 0 2 0 0 0 0 Network settings Input Undef Initial State Picture Boundary Condition 0 B= 0 0 0 0 0 0 0 0 0 z= 0,55 Simulator settings Running time 5 Time step 0,1 Output sampling 1 It’s near to the P2 task, but the result is depend from THRES’ is bias and from the diffusion. I tried smaller bias: AZ ÁBRÁKAT A FENTIEK SZERINT KÉSZITSD ÚJRA (az enyém valamivel finomabb…) The result of mine set: Mine Task 14 Task 4: This task was quite simple, because dr. Tamás Roska given the solution, when speak about dr. Ákos Zarándy, and write his template, which can explore the not connected lines. So this template is delete the connectless ends of the lines. The template running is depnds from the longest line. Template: 0 A= 1 0 1 2 1 0 1 0 B= 0 0 0 Network settings Input Picture Initial State Picture Boundary Condition Fixed 0 0 0.6 0 0 0 0 z= -1,5 Simulator settings Running time 5 Time step 0,1 Output sampling 1 LÉGYSZI AZ ÁTMENETET CSINÁLD ÚJRA, HOGY NE LEGYEN FELTŰNŐ, köszi :). Step-by-step: 0 1 2 3 4 5 After 100: So, the template is OK. 15 Task 5: Ha átfogalmazod a mondatokat, egy az egyben be is adhatod. The A template is simple, but the B template is designed, so that the b(-1,0) = -2 because this pixels should be white. The others should be black, these are greater than 0 in B, and the null means don’t care. The Temmaster gives a good result: Template: 0 A= 0 0 0 1 0 0 0 0 B= Network settings Input Picture Initial State Arbitrary Boundary Condition Zero-flux 1 2 0 -2 2 2 1 2 0 z= -9 Simulator settings Running time 1 Time step 0.1 Output sampling 1 16