Matching superimposed image

We are given two grayscale images, one of which contains a large, mostly contiguous patch from the other one. The patch can be altered with noise, its levels may be stretched, etc.

Here’s an example image with copied patch original image

We would like to determine the region of the image which was copied onto the other image.

My first instinct was to look at the local correlation. I first apply a little bit of blur to eliminate some of the noise. Then, around each point, I can subtract a gaussian average, then look at the covariance weighted by that same Gaussian kernel. I normalize by the variances, measured in the same way, to get a correlation. If $ G$ is the Gaussian blur operator, this is:

$ $ \frac{G(A \times B) – G(A)G(B)}{\sqrt{(G(A^2)-G(A)^2)(G(B^2)-G(B)^2)} $ $

The result is… not too bad, not great:

correlation

Playing with the width of the kernel can help a bit. I’ve also try correlating Laplacians instead of the images themselves, but it seems to hurt more than it helps. I’ve also tried using the watershed algorithm on the correlation, and it just didn’t give very good results.

I’m thinking part of my problem is not having a strong enough prior for what the patch should be like, perhaps a MRF would help here? Besides MRF, are there some other techniques, perhaps more lightweight that would apply? The other part is that correlation doesn’t seem to be all that great at measuring the distance. There are places where the correlation is very high despite the images being very visually distinct. What other metrics could be of use?

ReplaceAll with pattern matching not working with list of lists

Abstract This is just a learning exercise for me. I am trying to create a function that will take a list of vectors, multiply them by a constant if constant is given, and then add all vectors. If we have no constants then the list looks like this: {list1, list2,...}. However if we want to scale one or more vectors the list would look like this: {{c1,list}, {c2,list}}. I can get it to work with one list whether it has a constant or not but not for a list of lists.

u = {1, -2}; v = {2, -5}; c1 = 4; c2 = -3; vec1 = {u, c1}; vec2 = {c2, v}; ReplaceAll[{vec1, vec2}, {x_List, c_} -> c  x] (* gives wrong values *) vec1 /. {x_List, c_} -> c*x (* this works but not if x_List and c_ reordered *) {c1*u, c2*v} (* this is the value I am seeking *) 

Pattern matching on function application

Suppose we have a function f :: a -> b and a function g :: b -> a such that f . g = id. You might say that g is the “inverse” of f (and vice versa). Could we then pattern match on something like f x on the left hand side by replacing occurences of x with g x on the right hand side? For example:

-- Here, (- 3) is the "inverse" of (+ 3), or more generally, (- n) is the "inverse" of (+ n)  subtractThree (x + 3) = x subtractThree x = (x - 3) 

This just randomly came to my mind and I’m wondering if there is something fundamentally wrong with this.

Edit: This is my first post here and I’m unsure whether this is the right kind of question for this community. Please don’t hesitate to close this if this doesn’t belong here.

Stable matching with dynamic preference lists

I have a set $ F$ of $ n_1$ families, a set $ C$ of $ n_2$ children ($ n_1<n_2$ ) and a set $ M$ of feasible one-to-one matchings of the families with the children. All the children have the same preference list over the families, but the families have different preference lists.

Our objective is to select from the set $ M$ a stable matching. It is clear that the family with rank 1 will be matched with the child she ranks the best among those that is matched with them in $ M$ , the family with rank 2 will be matched with the child she ranks the best among those that is matched with them in the matchings selected for family 1 and so on.

When the preference lists are fixed, the constraint can be modeled as follows:

$ 1 \leq \sum\limits_{j’\in J^{\leq}_{C_j^i}(i)}x_{ij’} + \sum\limits_{i’\in F^{\leq}_{i}}x_{i’C_j^i} $ ; $ i \in F$ , $ j=1,\ldots,i$

with

  • $ x_{ij}$ equals one if family $ i$ is matched with rank $ j$ .
  • $ C_j^i$ is the child with rank $ j$ for family $ i$ .
  • $ J^{\leq}_{s}(i)$ is the set of children that family $ i$ ranks at the same level or better than child $ s$ .
  • $ C^{\leq}_{i}$ is the set of families that are at the same level or better than family $ i$ .

How to modify this constraint to take into account the changes in the preference lists?

Pattern Matching Algorithm in Java

I have to write an algorithm that solves below problem statement – –There is a project requirement which has list of titles (Developer, Java Developer,C++ Developer) applicable.

–There is a list of applicants who have titles like (Java Engineer , Software Developer).

Which algorithm can be used to find list of applicants that closely match the requirement?

Thank you!

Problem with understanding Multi-party security circuit for secure stable matching

Secure Multi-party Stable Matching Circuit I am reading the following paper: MPCircuits: Optimized Circuit Generation for Secure Multi-Party Computation

Paper Link

I have following questions:

  1. why Preference of group1 starts from L_0 where as preference list from group2 starts with L_(n/2+1)?
  2. Any reason why they used the priority encoder?
  3. What is the technique for the security of preference list?

Somebody please guide me. Zulfi.

Understanding the Secure Multi-party circuit for Stable Matching

I am reading the following paper:

MPCircuits: Optimized Circuit Generation for Secure Multi-Party Computation

link of paper

I have following questions:

  1. why Preference of group1 starts from L_0 where as preference list from group2 starts with L_(n/2+1)?

  2. Any reason why they used the priority encoder?

  3. Is their anything done for security of preference list ?

Somebody please guide me. Zulfi.

hardware for secure stable matching

Maximum Matching for Line Graphs

I tried to study the maximum matching for a line-graph , i.e , $ L(G)$ of a graph , $ G(V,E)$ , from here : https://www.sciencedirect.com/science/article/pii/S0012365X97001039

But could not understand it , can anybody explain it in detail .

I understood how to create the corresponding tree , but after that I could not understand the process of finding the maximum matching .

update matching column value in anywhere in database sqlserver

I have assetid column in multiple table in my Database and Asset(main) table

I want to update all occurences of tables in all occurences of inserts in database assetid column where value has 1020 to 1

update AdminInterests set assetid = 1 where 1020 

I just want to how to apply this update for entire database all tables with one query