


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Professor: Jacobs; Class: Image Processing; Subject: Computer Science; University: University of Maryland; Term: Unknown 1989;
Typology: Assignments
1 / 4
This page cannot be seen from the preview
Don't miss anything!



The goal of this problem set is to implement the texture synthesis method of Efros and Leung. This is described in the paper: ``Texture Synthesis by Non-parametric Sampling’’, by Efros and Leung, in the International Conference on Computer Vision,
for i,j do for ii,jj do dist = (Template(ii,jj)-SampleImage(i-ii,j-jj))^ SSD(i,j) = SSD(i,j) + distValidMask(ii,jj) end SSD(i,j) = SSD(i,j) / TotWeight End However, in Matlab, it will be more efficient to implement this without looping. Here are some hints on how to do this. First, notice that (T(ii,jj)-S(i-ii,j-jj))^2 = T(ii,jj)^2 – 2T(ii,jj)S(i-ii,j-jj) + S(i-ii,j-jj)^2. Notice also that we can compute: for i,j do for ii,jj do dist = Template(ii,jj)SampleImage(i-ii,j-jj); COR(i,j) = COR(i,j) + distValidMask(ii,jj) end end with one call to imfilter with SampleImage and (Template.ValidMask) as arguments. The other parts of SSD can also be computed without any explicit looping. We can compute: for i,j do for ii,jj do dist = SampleImage(i-ii,j-jj)^2; COR(i,j) = COR(i,j) + dist*ValidMask(ii,jj) end end by calling imfilter with SampleImage.^2 and ValidMask as arguments. Test your function using the checkerboard function that we provide. Execute the call: my_SSD(checkerboard(3,3),[0 1 1; 1 0 -1; 1 0 0], [1 1 1; 1 1 0; 1 1 1]) and turn in a printout of the results, along with your code.
I have removed the part of the pseudocode that deals with Gaussian filtering, for simplicity. function GrowImage(SampleImage,Image,WindowSize) while Image not filled do progress = 0 PixelList = GetUnfilledNeighbors(Image) foreach Pixel in PixelList do Template = GetNeighborhoodWindow(Pixel) BestMatches = FindMatches(Template, SampleImage) BestMatch = RandomPick(BestMatches) Pixel.value = BestMatch.value end return Image end Function GetUnfilledNeighbors() returns a list of all unfilled pixels that have filled pixels as their neighbors (the image is subtracted from its morphological dilation). The list is randomly permuted and then sorted by decreasing number of filled neighbor pixels. GetNeigborhoodWindow() returns a window of size WindowSize around a given pixel. RandomPick() picks an element randomly from the list. FindMatches() is as follows: function FindMatches(Template,SampleImage) ValidMask = 1s where Template is filled, 0s otherwise TotWeight = sum i,j ValidMask(i,j) for i,j do for ii,jj do dist = (Template(ii,jj)-SampleImage(i-ii,j-jj))^ SSD(i,j) = SSD(i,j) + distValidMask(ii,jj)GaussMask(ii,jj) end SSD(i,j) = SSD(i,j) / TotWeight end PixelList = all pixels (i,j) where SSD(i,j) <= min(SSD)*(1+ErrThreshold) return PixelList end In our implementation the constant were set as follows: ErrThreshold = 0.1. Pixel values are in the range of 0 to 1.