필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Selectively grab regions of pixels from one image to transcribe to another

조회 수: 1 (최근 30일)
Ariel Avshalumov
Ariel Avshalumov 2018년 7월 16일
마감: MATLAB Answer Bot 2021년 8월 20일
I want to take parts of an image (img1) and place them into a new image (img2).
What I am doing is selecting specific ranges of pixels from img1 and placing them in the same exact place as img2.
So what I did was:
img1 = I{1}; %just a cell with several images of size (256,256)
img2 = zeros(256,256);
img2(1,1,46,46) = imcrop(img1, [1,1,45,45]); %These pixel values are simplified for the example
I also want to do this iteratively, meaning that I'm adding several of these "squares" randomly taken from img1 into img 2.
In simple code it might look like:
for square = 1:50:300
img2(1+square,1+square,46,46) = imcrop(img1, [1+square,1+square,45,45]);
...
end
The code is a touch more complex than this (especially picking the squares) but the real issue is that the img1 doesn't transcribe well into the new img2. I'm getting a white image with some dark spots but not the images that I would like to see.
Here are some examples:
and an example starting image is:
Note that the starting image wasn't red (grayscale), this example image already had some processing done on it.
If I don't declare img2 = zeros(256,256) I do get the squares that I want but for some reason they are all disorganized and not usable for my purpose. Here is an example of that same image without a declared img2:
I'm not really sure what Matlab is doing so any advice would be great. I think that imoverlay might be a possibility but I'm not 100% if that is the best way to approach this problem.

답변 (0개)

이 질문은 마감되었습니다.

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by