How can i define part of image to work on (Specific pixel range) not whole image ?
조회 수: 6(최근 30일)
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
DGM 2022년 7월 25일
편집: DGM 2022년 7월 25일
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.
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:
inpict = imread('cameraman.tif');
% 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;