How can i define part of image to work on (Specific pixel range) not whole image ?

4 views (last 30 days)
Amr Azab on 25 Jul 2022
Edited: DGM on 3 Oct 2022
How can i define part of image to work on (Specific pixel range) not whole image, because the image i worked in, is too big 10000*10000 pixel
How can i define just 1000*1000 pixel from the Image to be able to make quick processing ?
i need for example to define the Top-Right side
Walter Roberson on 25 Jul 2022
Perhaps blockproc ?

DGM on 25 Jul 2022
Edited: DGM on 3 Oct 2022
Depending on your needs, you may be able to use roifilt2(). Example
Given a 2D (grayscale) image and a logical mask, roifilt2() works by extracting a rectangular image around the mask region, processing it, and then compositing the result with the original image segment. The composited segment is inserted back into the original image.
There are limitations with roifilt2(). Since it only accepts 2D inputs, it can't process anything that requires color information. For tasks which don't require color information, color images can be processed in an external loop, but this often degrades the speed advantage. Also, roifilt2() can't utilize anything other than logical masks. While I doubt you need an antialiased or soft mask, it's something worth noting.
I have a yet-unpublished MIMT replacement for roifilt2() which addresses both of these shortcomings, but I'm not going to post it unless there's a need. (EDIT: it's up now. Webdocs here)
Alternatively, if you can define your ROI based on subscript ranges, you can just use basic array indexing to extract the rectangular ROI, process it, and insert it back into the image.
Since you haven't mentioned what the actual task is, consider the example wherein the task is to apply a blur to the ROI:
% extract roi from image (northeast corner)
sz = size(inpict);
yrange = 1:128;
xrange = sz(2)-128-1:sz(2);
roi = inpict(yrange,xrange,:);
% process roi
roi = imgaussfilt(roi,5);
% insert roi back into image
inpict(yrange,xrange,:) = roi;
imshow(inpict)
Amr Azab on 25 Jul 2022
Thank you so much :)

Categories

Find more on ROI-Based Processing in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!