Apply convolution to a specific area of image











up vote
0
down vote

favorite












I'm trying to apply convolution to a rectangle with specific from an image.
If I use filter2d function it will apply convolution to entire image.



Also, I think a solution could be to crop the original image, apply filter2d to cropped image and copy cropped image over original image, but I don't think is the best solution.
How can I achieve convolution just for a specific area of image?










share|improve this question




















  • 4




    does subimaging work? cv::Rect yourImageRegion = cv::Rect(...); filter2D(image(yourImageRegion), image(yourImageRegion), ...);
    – Micka
    2 days ago










  • @Micka Yes, it works. But this is the most efficient way?
    – GameZone RO
    2 days ago










  • Memory usage should be O1, isn't it?
    – Victor Gubin
    2 days ago










  • subimaging is ecfficient. But in-place editing syntax ofzen isn't, because temporary memory will be allocated. So if you are working on multiple images of the same size (e.g videostream) it might be better to allocate and use different source and destination images (.clone) and then filter on their subimages.
    – Micka
    2 days ago












  • if only that subimage is relevant, you can use image(yourImageRegion).copyTo(...) where the target can be an empty Mat or a subimage of same size as the input (but different position if wanted).
    – Micka
    yesterday















up vote
0
down vote

favorite












I'm trying to apply convolution to a rectangle with specific from an image.
If I use filter2d function it will apply convolution to entire image.



Also, I think a solution could be to crop the original image, apply filter2d to cropped image and copy cropped image over original image, but I don't think is the best solution.
How can I achieve convolution just for a specific area of image?










share|improve this question




















  • 4




    does subimaging work? cv::Rect yourImageRegion = cv::Rect(...); filter2D(image(yourImageRegion), image(yourImageRegion), ...);
    – Micka
    2 days ago










  • @Micka Yes, it works. But this is the most efficient way?
    – GameZone RO
    2 days ago










  • Memory usage should be O1, isn't it?
    – Victor Gubin
    2 days ago










  • subimaging is ecfficient. But in-place editing syntax ofzen isn't, because temporary memory will be allocated. So if you are working on multiple images of the same size (e.g videostream) it might be better to allocate and use different source and destination images (.clone) and then filter on their subimages.
    – Micka
    2 days ago












  • if only that subimage is relevant, you can use image(yourImageRegion).copyTo(...) where the target can be an empty Mat or a subimage of same size as the input (but different position if wanted).
    – Micka
    yesterday













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm trying to apply convolution to a rectangle with specific from an image.
If I use filter2d function it will apply convolution to entire image.



Also, I think a solution could be to crop the original image, apply filter2d to cropped image and copy cropped image over original image, but I don't think is the best solution.
How can I achieve convolution just for a specific area of image?










share|improve this question















I'm trying to apply convolution to a rectangle with specific from an image.
If I use filter2d function it will apply convolution to entire image.



Also, I think a solution could be to crop the original image, apply filter2d to cropped image and copy cropped image over original image, but I don't think is the best solution.
How can I achieve convolution just for a specific area of image?







c++ opencv image-processing






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday

























asked 2 days ago









GameZone RO

1816




1816








  • 4




    does subimaging work? cv::Rect yourImageRegion = cv::Rect(...); filter2D(image(yourImageRegion), image(yourImageRegion), ...);
    – Micka
    2 days ago










  • @Micka Yes, it works. But this is the most efficient way?
    – GameZone RO
    2 days ago










  • Memory usage should be O1, isn't it?
    – Victor Gubin
    2 days ago










  • subimaging is ecfficient. But in-place editing syntax ofzen isn't, because temporary memory will be allocated. So if you are working on multiple images of the same size (e.g videostream) it might be better to allocate and use different source and destination images (.clone) and then filter on their subimages.
    – Micka
    2 days ago












  • if only that subimage is relevant, you can use image(yourImageRegion).copyTo(...) where the target can be an empty Mat or a subimage of same size as the input (but different position if wanted).
    – Micka
    yesterday














  • 4




    does subimaging work? cv::Rect yourImageRegion = cv::Rect(...); filter2D(image(yourImageRegion), image(yourImageRegion), ...);
    – Micka
    2 days ago










  • @Micka Yes, it works. But this is the most efficient way?
    – GameZone RO
    2 days ago










  • Memory usage should be O1, isn't it?
    – Victor Gubin
    2 days ago










  • subimaging is ecfficient. But in-place editing syntax ofzen isn't, because temporary memory will be allocated. So if you are working on multiple images of the same size (e.g videostream) it might be better to allocate and use different source and destination images (.clone) and then filter on their subimages.
    – Micka
    2 days ago












  • if only that subimage is relevant, you can use image(yourImageRegion).copyTo(...) where the target can be an empty Mat or a subimage of same size as the input (but different position if wanted).
    – Micka
    yesterday








4




4




does subimaging work? cv::Rect yourImageRegion = cv::Rect(...); filter2D(image(yourImageRegion), image(yourImageRegion), ...);
– Micka
2 days ago




does subimaging work? cv::Rect yourImageRegion = cv::Rect(...); filter2D(image(yourImageRegion), image(yourImageRegion), ...);
– Micka
2 days ago












@Micka Yes, it works. But this is the most efficient way?
– GameZone RO
2 days ago




@Micka Yes, it works. But this is the most efficient way?
– GameZone RO
2 days ago












Memory usage should be O1, isn't it?
– Victor Gubin
2 days ago




Memory usage should be O1, isn't it?
– Victor Gubin
2 days ago












subimaging is ecfficient. But in-place editing syntax ofzen isn't, because temporary memory will be allocated. So if you are working on multiple images of the same size (e.g videostream) it might be better to allocate and use different source and destination images (.clone) and then filter on their subimages.
– Micka
2 days ago






subimaging is ecfficient. But in-place editing syntax ofzen isn't, because temporary memory will be allocated. So if you are working on multiple images of the same size (e.g videostream) it might be better to allocate and use different source and destination images (.clone) and then filter on their subimages.
– Micka
2 days ago














if only that subimage is relevant, you can use image(yourImageRegion).copyTo(...) where the target can be an empty Mat or a subimage of same size as the input (but different position if wanted).
– Micka
yesterday




if only that subimage is relevant, you can use image(yourImageRegion).copyTo(...) where the target can be an empty Mat or a subimage of same size as the input (but different position if wanted).
– Micka
yesterday

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
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',
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
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372632%2fapply-convolution-to-a-specific-area-of-image%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372632%2fapply-convolution-to-a-specific-area-of-image%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

Wiesbaden

Marschland

Dieringhausen