About Sum of Squared differences
$begingroup$
I found a paragraph in the book about $SSD$, can't get one thing:
Most commonly, the distance measure is the sum of squared differences.
For two images $f(x, y)$ and $g (x, y)$ it is defined as $$
SSD(d_1,d_2) = sum_{i=-n_1}^{n_1} sum_{j=-n_2}^{n_2}
big(f(x+i,,y+j)-g(x+i-d_1,,y+j-d_2)big)^2
$$
where the summation extends over the region of size $(2n_1 + 1) times (2n_2 + 1)$.
I can not get, why does $i$ changes from $-n_1$ to $n_1$, but not from $0$ to $n_1$. The similar about $j$.
And why does summation goes over the $(2n_1 + 1) times (2n_2 + 1)$ but not over the $(n_1) times (n_2)$
image-processing
$endgroup$
migrated from stackoverflow.com Jun 22 '12 at 18:35
This question came from our site for professional and enthusiast programmers.
add a comment |
$begingroup$
I found a paragraph in the book about $SSD$, can't get one thing:
Most commonly, the distance measure is the sum of squared differences.
For two images $f(x, y)$ and $g (x, y)$ it is defined as $$
SSD(d_1,d_2) = sum_{i=-n_1}^{n_1} sum_{j=-n_2}^{n_2}
big(f(x+i,,y+j)-g(x+i-d_1,,y+j-d_2)big)^2
$$
where the summation extends over the region of size $(2n_1 + 1) times (2n_2 + 1)$.
I can not get, why does $i$ changes from $-n_1$ to $n_1$, but not from $0$ to $n_1$. The similar about $j$.
And why does summation goes over the $(2n_1 + 1) times (2n_2 + 1)$ but not over the $(n_1) times (n_2)$
image-processing
$endgroup$
migrated from stackoverflow.com Jun 22 '12 at 18:35
This question came from our site for professional and enthusiast programmers.
1
$begingroup$
(0, 0) represents the pixel in question. In order to go both positive and negative in both axes it is required to use both strictly positive (e.g. n<sub>1</sub>) and strictly negative (e.g. -n<sub>1</sub>) offsets.
$endgroup$
– Ignacio Vazquez-Abrams
Jun 21 '12 at 19:06
$begingroup$
But in Matrix, there are no negative offsets oO
$endgroup$
– user1448906
Jun 21 '12 at 19:17
$begingroup$
As defined, SSD(d1,d2) appears to be an image itself for each d1 and d2: It depends on x and y. This might be correct, but I am unsure.
$endgroup$
– willem
Jun 21 '12 at 19:26
1
$begingroup$
It seems that $(i, j)$ represents the offset from the point $(x, y)$. So, for example, $(i, j) = (0, 0)$ corresponds to the point $(x, y)$ itself. The collection of $(i, j)$ that you sum over forms a $2$-dimensional array (matrix if you like) that happens to be indexed where $(0, 0)$ is in the middle. This is okay and makes a lot of sense, given the context. You can define $k = i + n_1 + 1$ and see that it ranges from $1$ to $2n_1 + 1$ if you insist. Analogously, for $ell = j + n_2 + 1$.
$endgroup$
– Sammy Black
Dec 13 '13 at 22:01
$begingroup$
because it is used for finding correlation...its similar to convolution...therefore consideration starts when the last pixel of first image is multiplied with the first pixel of the second image and continues till first pixel of the first image is multiplied with the last pixel of the second image... hint: refer to convolution (see esp overlapping technique)
$endgroup$
– user155823
Jun 7 '14 at 18:31
add a comment |
$begingroup$
I found a paragraph in the book about $SSD$, can't get one thing:
Most commonly, the distance measure is the sum of squared differences.
For two images $f(x, y)$ and $g (x, y)$ it is defined as $$
SSD(d_1,d_2) = sum_{i=-n_1}^{n_1} sum_{j=-n_2}^{n_2}
big(f(x+i,,y+j)-g(x+i-d_1,,y+j-d_2)big)^2
$$
where the summation extends over the region of size $(2n_1 + 1) times (2n_2 + 1)$.
I can not get, why does $i$ changes from $-n_1$ to $n_1$, but not from $0$ to $n_1$. The similar about $j$.
And why does summation goes over the $(2n_1 + 1) times (2n_2 + 1)$ but not over the $(n_1) times (n_2)$
image-processing
$endgroup$
I found a paragraph in the book about $SSD$, can't get one thing:
Most commonly, the distance measure is the sum of squared differences.
For two images $f(x, y)$ and $g (x, y)$ it is defined as $$
SSD(d_1,d_2) = sum_{i=-n_1}^{n_1} sum_{j=-n_2}^{n_2}
big(f(x+i,,y+j)-g(x+i-d_1,,y+j-d_2)big)^2
$$
where the summation extends over the region of size $(2n_1 + 1) times (2n_2 + 1)$.
I can not get, why does $i$ changes from $-n_1$ to $n_1$, but not from $0$ to $n_1$. The similar about $j$.
And why does summation goes over the $(2n_1 + 1) times (2n_2 + 1)$ but not over the $(n_1) times (n_2)$
image-processing
image-processing
edited Dec 13 '13 at 21:55
Sammy Black
12.2k21636
12.2k21636
asked Jun 21 '12 at 18:07
user1448906
migrated from stackoverflow.com Jun 22 '12 at 18:35
This question came from our site for professional and enthusiast programmers.
migrated from stackoverflow.com Jun 22 '12 at 18:35
This question came from our site for professional and enthusiast programmers.
1
$begingroup$
(0, 0) represents the pixel in question. In order to go both positive and negative in both axes it is required to use both strictly positive (e.g. n<sub>1</sub>) and strictly negative (e.g. -n<sub>1</sub>) offsets.
$endgroup$
– Ignacio Vazquez-Abrams
Jun 21 '12 at 19:06
$begingroup$
But in Matrix, there are no negative offsets oO
$endgroup$
– user1448906
Jun 21 '12 at 19:17
$begingroup$
As defined, SSD(d1,d2) appears to be an image itself for each d1 and d2: It depends on x and y. This might be correct, but I am unsure.
$endgroup$
– willem
Jun 21 '12 at 19:26
1
$begingroup$
It seems that $(i, j)$ represents the offset from the point $(x, y)$. So, for example, $(i, j) = (0, 0)$ corresponds to the point $(x, y)$ itself. The collection of $(i, j)$ that you sum over forms a $2$-dimensional array (matrix if you like) that happens to be indexed where $(0, 0)$ is in the middle. This is okay and makes a lot of sense, given the context. You can define $k = i + n_1 + 1$ and see that it ranges from $1$ to $2n_1 + 1$ if you insist. Analogously, for $ell = j + n_2 + 1$.
$endgroup$
– Sammy Black
Dec 13 '13 at 22:01
$begingroup$
because it is used for finding correlation...its similar to convolution...therefore consideration starts when the last pixel of first image is multiplied with the first pixel of the second image and continues till first pixel of the first image is multiplied with the last pixel of the second image... hint: refer to convolution (see esp overlapping technique)
$endgroup$
– user155823
Jun 7 '14 at 18:31
add a comment |
1
$begingroup$
(0, 0) represents the pixel in question. In order to go both positive and negative in both axes it is required to use both strictly positive (e.g. n<sub>1</sub>) and strictly negative (e.g. -n<sub>1</sub>) offsets.
$endgroup$
– Ignacio Vazquez-Abrams
Jun 21 '12 at 19:06
$begingroup$
But in Matrix, there are no negative offsets oO
$endgroup$
– user1448906
Jun 21 '12 at 19:17
$begingroup$
As defined, SSD(d1,d2) appears to be an image itself for each d1 and d2: It depends on x and y. This might be correct, but I am unsure.
$endgroup$
– willem
Jun 21 '12 at 19:26
1
$begingroup$
It seems that $(i, j)$ represents the offset from the point $(x, y)$. So, for example, $(i, j) = (0, 0)$ corresponds to the point $(x, y)$ itself. The collection of $(i, j)$ that you sum over forms a $2$-dimensional array (matrix if you like) that happens to be indexed where $(0, 0)$ is in the middle. This is okay and makes a lot of sense, given the context. You can define $k = i + n_1 + 1$ and see that it ranges from $1$ to $2n_1 + 1$ if you insist. Analogously, for $ell = j + n_2 + 1$.
$endgroup$
– Sammy Black
Dec 13 '13 at 22:01
$begingroup$
because it is used for finding correlation...its similar to convolution...therefore consideration starts when the last pixel of first image is multiplied with the first pixel of the second image and continues till first pixel of the first image is multiplied with the last pixel of the second image... hint: refer to convolution (see esp overlapping technique)
$endgroup$
– user155823
Jun 7 '14 at 18:31
1
1
$begingroup$
(0, 0) represents the pixel in question. In order to go both positive and negative in both axes it is required to use both strictly positive (e.g. n<sub>1</sub>) and strictly negative (e.g. -n<sub>1</sub>) offsets.
$endgroup$
– Ignacio Vazquez-Abrams
Jun 21 '12 at 19:06
$begingroup$
(0, 0) represents the pixel in question. In order to go both positive and negative in both axes it is required to use both strictly positive (e.g. n<sub>1</sub>) and strictly negative (e.g. -n<sub>1</sub>) offsets.
$endgroup$
– Ignacio Vazquez-Abrams
Jun 21 '12 at 19:06
$begingroup$
But in Matrix, there are no negative offsets oO
$endgroup$
– user1448906
Jun 21 '12 at 19:17
$begingroup$
But in Matrix, there are no negative offsets oO
$endgroup$
– user1448906
Jun 21 '12 at 19:17
$begingroup$
As defined, SSD(d1,d2) appears to be an image itself for each d1 and d2: It depends on x and y. This might be correct, but I am unsure.
$endgroup$
– willem
Jun 21 '12 at 19:26
$begingroup$
As defined, SSD(d1,d2) appears to be an image itself for each d1 and d2: It depends on x and y. This might be correct, but I am unsure.
$endgroup$
– willem
Jun 21 '12 at 19:26
1
1
$begingroup$
It seems that $(i, j)$ represents the offset from the point $(x, y)$. So, for example, $(i, j) = (0, 0)$ corresponds to the point $(x, y)$ itself. The collection of $(i, j)$ that you sum over forms a $2$-dimensional array (matrix if you like) that happens to be indexed where $(0, 0)$ is in the middle. This is okay and makes a lot of sense, given the context. You can define $k = i + n_1 + 1$ and see that it ranges from $1$ to $2n_1 + 1$ if you insist. Analogously, for $ell = j + n_2 + 1$.
$endgroup$
– Sammy Black
Dec 13 '13 at 22:01
$begingroup$
It seems that $(i, j)$ represents the offset from the point $(x, y)$. So, for example, $(i, j) = (0, 0)$ corresponds to the point $(x, y)$ itself. The collection of $(i, j)$ that you sum over forms a $2$-dimensional array (matrix if you like) that happens to be indexed where $(0, 0)$ is in the middle. This is okay and makes a lot of sense, given the context. You can define $k = i + n_1 + 1$ and see that it ranges from $1$ to $2n_1 + 1$ if you insist. Analogously, for $ell = j + n_2 + 1$.
$endgroup$
– Sammy Black
Dec 13 '13 at 22:01
$begingroup$
because it is used for finding correlation...its similar to convolution...therefore consideration starts when the last pixel of first image is multiplied with the first pixel of the second image and continues till first pixel of the first image is multiplied with the last pixel of the second image... hint: refer to convolution (see esp overlapping technique)
$endgroup$
– user155823
Jun 7 '14 at 18:31
$begingroup$
because it is used for finding correlation...its similar to convolution...therefore consideration starts when the last pixel of first image is multiplied with the first pixel of the second image and continues till first pixel of the first image is multiplied with the last pixel of the second image... hint: refer to convolution (see esp overlapping technique)
$endgroup$
– user155823
Jun 7 '14 at 18:31
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
The region, $n_1×n_2$, starts from $1$. That is, $n_1,n_2$ start from $0$.
The region according to the formula is always odd, with windows of size: $1x1, 3x3, 5x5,.. $ or even $1x3, 1x5, .., 3x1$ and so on.
For example, if you are comparing two pixels (i.e. one pixel in each image), you have a region of $1$ pixel. Let's say it is the fifth pixel in the first row: x = $0$, y = $4$. The pixel values are $10,3$ for $f,g$ respectively. For the region of one$ 2n_1= 1 =>n_1 = 0$, and the same goes for $n_2$.
$SSD= (f(x+i,y+j) - g(x+i,y+j))^2$
$SSD= (f(0+0,4+0) - g(0+0,4+0))^2$
$SSD= (f(0,4) - g(0,4))^2$
$SSD= (10 - 3)^2 = 49$
Basically, you are comparing the value of the same pixel location with no offset around it.
If the window size is bigger, you are squaring the summation of the differences between the according pixels in that window.
$endgroup$
add a comment |
$begingroup$
Certainly one could iterate a sum from $i = 0$ to $n_1$ and from $j=0$ to $n_2.$ The question is, what is the purpose of the sum?
The indexing scheme in the formula is apparently intended to extract two rectangular regions out of two much larger images.
The rectangular regions are parallel to the coordinate axes,
but each rectangle has a width, a height, and a position that need to be specified.
For reasons that may be explained in the parts of the book that have been omitted from the question, the author wanted to specify the position of each rectangle by the coordinates of a pixel in the exact center of the rectangle.
Perhaps this is due to considerations of symmetry, or perhaps it is because we are really supposed to be interested in what is happening at a specific pixel in each image, and the other pixels are considered only as "neighbors" of the interesting pixel.
Whatever the motivation is, we get a rectangle by selecting a certain pixel to be in the center of the rectangle, and then extending the rectangle $n_1$ pixels to the left and to the right and $n_2$ pixels upward and downward.
The coordinates of the center of the rectangle inside the $f$ image are
$(x,y),$ so the rectangle runs left and right from $x - n_1$ to $x + n_1$
and vertically from $y - n_2$ to $y + n_2.$
The coordinates of the center of the rectangle in side the $g$ image are
not necessarily the same as those of the $f$ rectangle.
Instead of $(x,y),$ they are $(x-d_1,y-d_2),$
so the rectangle runs left and right from $(x - d_1) - n_1$ to
$(x - d_1) + n_1$ and vertically from $(y - d_2) - n_2$ to $(y - d_2) + n_2.$
If you take all the integers from $x - n_1$ to $x + n_1,$
there are $2n_1 + 1$ of them,
so the $f$ rectangle is $2n_1 + 1$ pixels wide.
For similar reasons, it is $2n_1 + 1$ pixels high,
and the $g$ rectangle is the same size.
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f161780%2fabout-sum-of-squared-differences%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
The region, $n_1×n_2$, starts from $1$. That is, $n_1,n_2$ start from $0$.
The region according to the formula is always odd, with windows of size: $1x1, 3x3, 5x5,.. $ or even $1x3, 1x5, .., 3x1$ and so on.
For example, if you are comparing two pixels (i.e. one pixel in each image), you have a region of $1$ pixel. Let's say it is the fifth pixel in the first row: x = $0$, y = $4$. The pixel values are $10,3$ for $f,g$ respectively. For the region of one$ 2n_1= 1 =>n_1 = 0$, and the same goes for $n_2$.
$SSD= (f(x+i,y+j) - g(x+i,y+j))^2$
$SSD= (f(0+0,4+0) - g(0+0,4+0))^2$
$SSD= (f(0,4) - g(0,4))^2$
$SSD= (10 - 3)^2 = 49$
Basically, you are comparing the value of the same pixel location with no offset around it.
If the window size is bigger, you are squaring the summation of the differences between the according pixels in that window.
$endgroup$
add a comment |
$begingroup$
The region, $n_1×n_2$, starts from $1$. That is, $n_1,n_2$ start from $0$.
The region according to the formula is always odd, with windows of size: $1x1, 3x3, 5x5,.. $ or even $1x3, 1x5, .., 3x1$ and so on.
For example, if you are comparing two pixels (i.e. one pixel in each image), you have a region of $1$ pixel. Let's say it is the fifth pixel in the first row: x = $0$, y = $4$. The pixel values are $10,3$ for $f,g$ respectively. For the region of one$ 2n_1= 1 =>n_1 = 0$, and the same goes for $n_2$.
$SSD= (f(x+i,y+j) - g(x+i,y+j))^2$
$SSD= (f(0+0,4+0) - g(0+0,4+0))^2$
$SSD= (f(0,4) - g(0,4))^2$
$SSD= (10 - 3)^2 = 49$
Basically, you are comparing the value of the same pixel location with no offset around it.
If the window size is bigger, you are squaring the summation of the differences between the according pixels in that window.
$endgroup$
add a comment |
$begingroup$
The region, $n_1×n_2$, starts from $1$. That is, $n_1,n_2$ start from $0$.
The region according to the formula is always odd, with windows of size: $1x1, 3x3, 5x5,.. $ or even $1x3, 1x5, .., 3x1$ and so on.
For example, if you are comparing two pixels (i.e. one pixel in each image), you have a region of $1$ pixel. Let's say it is the fifth pixel in the first row: x = $0$, y = $4$. The pixel values are $10,3$ for $f,g$ respectively. For the region of one$ 2n_1= 1 =>n_1 = 0$, and the same goes for $n_2$.
$SSD= (f(x+i,y+j) - g(x+i,y+j))^2$
$SSD= (f(0+0,4+0) - g(0+0,4+0))^2$
$SSD= (f(0,4) - g(0,4))^2$
$SSD= (10 - 3)^2 = 49$
Basically, you are comparing the value of the same pixel location with no offset around it.
If the window size is bigger, you are squaring the summation of the differences between the according pixels in that window.
$endgroup$
The region, $n_1×n_2$, starts from $1$. That is, $n_1,n_2$ start from $0$.
The region according to the formula is always odd, with windows of size: $1x1, 3x3, 5x5,.. $ or even $1x3, 1x5, .., 3x1$ and so on.
For example, if you are comparing two pixels (i.e. one pixel in each image), you have a region of $1$ pixel. Let's say it is the fifth pixel in the first row: x = $0$, y = $4$. The pixel values are $10,3$ for $f,g$ respectively. For the region of one$ 2n_1= 1 =>n_1 = 0$, and the same goes for $n_2$.
$SSD= (f(x+i,y+j) - g(x+i,y+j))^2$
$SSD= (f(0+0,4+0) - g(0+0,4+0))^2$
$SSD= (f(0,4) - g(0,4))^2$
$SSD= (10 - 3)^2 = 49$
Basically, you are comparing the value of the same pixel location with no offset around it.
If the window size is bigger, you are squaring the summation of the differences between the according pixels in that window.
answered Sep 18 '17 at 16:44
N. OsilN. Osil
1011
1011
add a comment |
add a comment |
$begingroup$
Certainly one could iterate a sum from $i = 0$ to $n_1$ and from $j=0$ to $n_2.$ The question is, what is the purpose of the sum?
The indexing scheme in the formula is apparently intended to extract two rectangular regions out of two much larger images.
The rectangular regions are parallel to the coordinate axes,
but each rectangle has a width, a height, and a position that need to be specified.
For reasons that may be explained in the parts of the book that have been omitted from the question, the author wanted to specify the position of each rectangle by the coordinates of a pixel in the exact center of the rectangle.
Perhaps this is due to considerations of symmetry, or perhaps it is because we are really supposed to be interested in what is happening at a specific pixel in each image, and the other pixels are considered only as "neighbors" of the interesting pixel.
Whatever the motivation is, we get a rectangle by selecting a certain pixel to be in the center of the rectangle, and then extending the rectangle $n_1$ pixels to the left and to the right and $n_2$ pixels upward and downward.
The coordinates of the center of the rectangle inside the $f$ image are
$(x,y),$ so the rectangle runs left and right from $x - n_1$ to $x + n_1$
and vertically from $y - n_2$ to $y + n_2.$
The coordinates of the center of the rectangle in side the $g$ image are
not necessarily the same as those of the $f$ rectangle.
Instead of $(x,y),$ they are $(x-d_1,y-d_2),$
so the rectangle runs left and right from $(x - d_1) - n_1$ to
$(x - d_1) + n_1$ and vertically from $(y - d_2) - n_2$ to $(y - d_2) + n_2.$
If you take all the integers from $x - n_1$ to $x + n_1,$
there are $2n_1 + 1$ of them,
so the $f$ rectangle is $2n_1 + 1$ pixels wide.
For similar reasons, it is $2n_1 + 1$ pixels high,
and the $g$ rectangle is the same size.
$endgroup$
add a comment |
$begingroup$
Certainly one could iterate a sum from $i = 0$ to $n_1$ and from $j=0$ to $n_2.$ The question is, what is the purpose of the sum?
The indexing scheme in the formula is apparently intended to extract two rectangular regions out of two much larger images.
The rectangular regions are parallel to the coordinate axes,
but each rectangle has a width, a height, and a position that need to be specified.
For reasons that may be explained in the parts of the book that have been omitted from the question, the author wanted to specify the position of each rectangle by the coordinates of a pixel in the exact center of the rectangle.
Perhaps this is due to considerations of symmetry, or perhaps it is because we are really supposed to be interested in what is happening at a specific pixel in each image, and the other pixels are considered only as "neighbors" of the interesting pixel.
Whatever the motivation is, we get a rectangle by selecting a certain pixel to be in the center of the rectangle, and then extending the rectangle $n_1$ pixels to the left and to the right and $n_2$ pixels upward and downward.
The coordinates of the center of the rectangle inside the $f$ image are
$(x,y),$ so the rectangle runs left and right from $x - n_1$ to $x + n_1$
and vertically from $y - n_2$ to $y + n_2.$
The coordinates of the center of the rectangle in side the $g$ image are
not necessarily the same as those of the $f$ rectangle.
Instead of $(x,y),$ they are $(x-d_1,y-d_2),$
so the rectangle runs left and right from $(x - d_1) - n_1$ to
$(x - d_1) + n_1$ and vertically from $(y - d_2) - n_2$ to $(y - d_2) + n_2.$
If you take all the integers from $x - n_1$ to $x + n_1,$
there are $2n_1 + 1$ of them,
so the $f$ rectangle is $2n_1 + 1$ pixels wide.
For similar reasons, it is $2n_1 + 1$ pixels high,
and the $g$ rectangle is the same size.
$endgroup$
add a comment |
$begingroup$
Certainly one could iterate a sum from $i = 0$ to $n_1$ and from $j=0$ to $n_2.$ The question is, what is the purpose of the sum?
The indexing scheme in the formula is apparently intended to extract two rectangular regions out of two much larger images.
The rectangular regions are parallel to the coordinate axes,
but each rectangle has a width, a height, and a position that need to be specified.
For reasons that may be explained in the parts of the book that have been omitted from the question, the author wanted to specify the position of each rectangle by the coordinates of a pixel in the exact center of the rectangle.
Perhaps this is due to considerations of symmetry, or perhaps it is because we are really supposed to be interested in what is happening at a specific pixel in each image, and the other pixels are considered only as "neighbors" of the interesting pixel.
Whatever the motivation is, we get a rectangle by selecting a certain pixel to be in the center of the rectangle, and then extending the rectangle $n_1$ pixels to the left and to the right and $n_2$ pixels upward and downward.
The coordinates of the center of the rectangle inside the $f$ image are
$(x,y),$ so the rectangle runs left and right from $x - n_1$ to $x + n_1$
and vertically from $y - n_2$ to $y + n_2.$
The coordinates of the center of the rectangle in side the $g$ image are
not necessarily the same as those of the $f$ rectangle.
Instead of $(x,y),$ they are $(x-d_1,y-d_2),$
so the rectangle runs left and right from $(x - d_1) - n_1$ to
$(x - d_1) + n_1$ and vertically from $(y - d_2) - n_2$ to $(y - d_2) + n_2.$
If you take all the integers from $x - n_1$ to $x + n_1,$
there are $2n_1 + 1$ of them,
so the $f$ rectangle is $2n_1 + 1$ pixels wide.
For similar reasons, it is $2n_1 + 1$ pixels high,
and the $g$ rectangle is the same size.
$endgroup$
Certainly one could iterate a sum from $i = 0$ to $n_1$ and from $j=0$ to $n_2.$ The question is, what is the purpose of the sum?
The indexing scheme in the formula is apparently intended to extract two rectangular regions out of two much larger images.
The rectangular regions are parallel to the coordinate axes,
but each rectangle has a width, a height, and a position that need to be specified.
For reasons that may be explained in the parts of the book that have been omitted from the question, the author wanted to specify the position of each rectangle by the coordinates of a pixel in the exact center of the rectangle.
Perhaps this is due to considerations of symmetry, or perhaps it is because we are really supposed to be interested in what is happening at a specific pixel in each image, and the other pixels are considered only as "neighbors" of the interesting pixel.
Whatever the motivation is, we get a rectangle by selecting a certain pixel to be in the center of the rectangle, and then extending the rectangle $n_1$ pixels to the left and to the right and $n_2$ pixels upward and downward.
The coordinates of the center of the rectangle inside the $f$ image are
$(x,y),$ so the rectangle runs left and right from $x - n_1$ to $x + n_1$
and vertically from $y - n_2$ to $y + n_2.$
The coordinates of the center of the rectangle in side the $g$ image are
not necessarily the same as those of the $f$ rectangle.
Instead of $(x,y),$ they are $(x-d_1,y-d_2),$
so the rectangle runs left and right from $(x - d_1) - n_1$ to
$(x - d_1) + n_1$ and vertically from $(y - d_2) - n_2$ to $(y - d_2) + n_2.$
If you take all the integers from $x - n_1$ to $x + n_1,$
there are $2n_1 + 1$ of them,
so the $f$ rectangle is $2n_1 + 1$ pixels wide.
For similar reasons, it is $2n_1 + 1$ pixels high,
and the $g$ rectangle is the same size.
answered Jul 19 '18 at 12:41
David KDavid K
53.7k342116
53.7k342116
add a comment |
add a comment |
Thanks for contributing an answer to Mathematics Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f161780%2fabout-sum-of-squared-differences%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
$begingroup$
(0, 0) represents the pixel in question. In order to go both positive and negative in both axes it is required to use both strictly positive (e.g. n<sub>1</sub>) and strictly negative (e.g. -n<sub>1</sub>) offsets.
$endgroup$
– Ignacio Vazquez-Abrams
Jun 21 '12 at 19:06
$begingroup$
But in Matrix, there are no negative offsets oO
$endgroup$
– user1448906
Jun 21 '12 at 19:17
$begingroup$
As defined, SSD(d1,d2) appears to be an image itself for each d1 and d2: It depends on x and y. This might be correct, but I am unsure.
$endgroup$
– willem
Jun 21 '12 at 19:26
1
$begingroup$
It seems that $(i, j)$ represents the offset from the point $(x, y)$. So, for example, $(i, j) = (0, 0)$ corresponds to the point $(x, y)$ itself. The collection of $(i, j)$ that you sum over forms a $2$-dimensional array (matrix if you like) that happens to be indexed where $(0, 0)$ is in the middle. This is okay and makes a lot of sense, given the context. You can define $k = i + n_1 + 1$ and see that it ranges from $1$ to $2n_1 + 1$ if you insist. Analogously, for $ell = j + n_2 + 1$.
$endgroup$
– Sammy Black
Dec 13 '13 at 22:01
$begingroup$
because it is used for finding correlation...its similar to convolution...therefore consideration starts when the last pixel of first image is multiplied with the first pixel of the second image and continues till first pixel of the first image is multiplied with the last pixel of the second image... hint: refer to convolution (see esp overlapping technique)
$endgroup$
– user155823
Jun 7 '14 at 18:31