Overlapping Patches

125 views
Skip to first unread message

Grace Goo

unread,
Sep 26, 2012, 12:38:14 AM9/26/12
to cs498-...@googlegroups.com
Hi, I'm just a bit confused about this line: "Once the cost of each patch has been computed, randomly choose on patch whose cost is less than a threshold determined by tol (see description of choose_sample below)."

 So I get that we first have to pick a random patch as our upper-left corner, and pick another random patch that overlaps the first one, etc. But I am confused as to what happens after that. What does the "cost" mean? In the lecture slides, we only deal with cost when we're finding the shortest path. I thought the quilt_simple wouldn't be looking for the shortest path, but would just do a straight overlap line? 

If we're picking the best patch, does that mean we have to try out multiple random patches for each overlap and pick the best one?

Thanks in advance,

Arun Mallya

unread,
Sep 26, 2012, 12:53:17 AM9/26/12
to cs498-...@googlegroups.com
Cost here would be the SSD of the overlapping patches. You try out all patches, and select one from those that have the least SSD.

Grace Goo

unread,
Sep 26, 2012, 12:56:23 AM9/26/12
to cs498-...@googlegroups.com
What do you mean by trying out all patches? Aren't the patches selected randomly just like the quilt_random function? And if they're selected randomly how do we know that we've tried them all out?

Nan Chen

unread,
Sep 26, 2012, 12:58:19 AM9/26/12
to cs498-...@googlegroups.com
I'm a little confused about how to find patches. there are 2 ideas in my mind:
1. slice the original sample image into patches, and when you find the similar patch for the current patch, go through all the sliced patches I have to calculate ssd.
2. to find the similar patch for the current one, go through the whole original sample image, from upper-left, and move pixels 1-by-1.

which one is right?

在 2012年9月25日星期二UTC-5下午11时53分17秒,Arun Mallya写道:

Arun Mallya

unread,
Sep 26, 2012, 12:59:49 AM9/26/12
to cs498-...@googlegroups.com
In the quilt_random(), we select patches randomly.

In the other two functions, we check every possible candidate patch, and find its SSD (through filtering the whole image). 

For every pixel in image that can be the center of some patch, find the SSD of that patch with the place to be filled up.

Grace Goo

unread,
Sep 26, 2012, 1:02:24 AM9/26/12
to cs498-...@googlegroups.com
What qualifies as a candidate patch? If the image was 4x4 for example, with each pixel being 1x1, do we just divide up the picture into 16 patches? And the first patch would just be a random patch out of these 16? 

Arun Mallya

unread,
Sep 26, 2012, 1:08:30 AM9/26/12
to cs498-...@googlegroups.com
Suppose you have an image of size 5x5, and each patch is of size 1x1.

Then you can have a total of 25 patches.

If each patch if of size 3x3, then you can have 9 patches that fit inside the 5x5 patch.

And so on...

Grace Goo

unread,
Sep 26, 2012, 1:09:30 AM9/26/12
to cs498-...@googlegroups.com
Okay thanks!

--
 
 



--
Grace Yeon Goo
College of Engineering - Computer Engineering
Minor in Mathematics
University of Illinois at Urbana-Champaign
Class of 2013
gg...@illinois.edu
773) 704 - 1257

Grace Goo

unread,
Sep 26, 2012, 11:52:02 PM9/26/12
to cs498-...@googlegroups.com
I'm sorry, I just have one more question. I'm doubting whether I have to right approach because my approach seems like it's going to be really really slow.
For every single overlap, we have to look through all of our patches? Isn't that going to take forever?

On Tuesday, September 25, 2012 11:38:14 PM UTC-5, Grace Goo wrote:

Arun Mallya

unread,
Sep 26, 2012, 11:59:42 PM9/26/12
to cs498-...@googlegroups.com
It's decently fast if you use filtering.

Hoiem, Derek W

unread,
Sep 27, 2012, 12:00:01 AM9/27/12
to cs498-...@googlegroups.com

It might be slow, depending on how you implement.  Remember from class that SSD can be performed via filtering operations, something like:

ssd = imfilter(im.^2,  ones(size(template))) - 2*imfilter(im, template) + sum(template(:).^2);

Note that the first term can be precomputed and cached, since it depends only on the size of the template. 

 

I suggest that you start by working with a small output image until you get it working.

 

Best,

Derek

--
 
 

Nan Chen

unread,
Sep 27, 2012, 2:22:25 AM9/27/12
to cs498-...@googlegroups.com
What the size of your template? the same size with patch? or just overlap region?
if is the later one, and if upper and left are already filled, how to make a template with 2 overlap region?

On Sep 26, 2012, at 11:00 PM, "Hoiem, Derek W" <dho...@illinois.edu> wrote:

It might be slow, depending on how you implement.  Remember from class that SSD can be performed via filtering operations, something like:
ssd = imfilter(im.^2,  ones(size(template))) - 2*imfilter(im, template) + sum(template(:).^2);
Note that the first term can be precomputed and cached, since it depends only on the size of the template. 
 
I suggest that you start by working with a small output image until you get it working.
 
Best,
Derek
 
From: cs498-...@googlegroups.com [mailto:cs498-cp-...@googlegroups.com] On Behalf Of Grace Goo
Sent: Wednesday, September 26, 2012 10:52 PM
To: cs498-...@googlegroups.com
Subject: Re: Overlapping Patches
 
I'm sorry, I just have one more question. I'm doubting whether I have to right approach because my approach seems like it's going to be really really slow.
For every single overlap, we have to look through all of our patches? Isn't that going to take forever?

On Tuesday, September 25, 2012 11:38:14 PM UTC-5, Grace Goo wrote:
Hi, I'm just a bit confused about this line: "Once the cost of each patch has been computed, randomly choose on patch whose cost is less than a threshold determined by tol (see description of choose_sample below)."
 
 So I get that we first have to pick a random patch as our upper-left corner, and pick another random patch that overlaps the first one, etc. But I am confused as to what happens after that. What does the "cost" mean? In the lecture slides, we only deal with cost when we're finding the shortest path. I thought the quilt_simple wouldn't be looking for the shortest path, but would just do a straight overlap line? 
 
If we're picking the best patch, does that mean we have to try out multiple random patches for each overlap and pick the best one?
 
Thanks in advance,
-- 
 
 

--    

Reply all
Reply to author
Forward
0 new messages