Moving viewing window over an image

3 ビュー (過去 30 日間)
Bryan Qi Zheng Leong
Bryan Qi Zheng Leong 2021 年 2 月 23 日
回答済み: Tarunbir Gambhir 2021 年 3 月 23 日
Hi,
I want to move a viewing window over an image (from top to bottom) in 6 seconds. For instance, I have a grey image (500*500px), the window will replace this grey image with another image (e.g., a face). Observers will see that the moving window is revealing the face part-by-part. However, as the window moves downward, the top part of the image which is "outside of the window" is again replaced by the grey image.
I was thinking 'for loop' the image to create the window, 'if' to replace the image, but not sure how to make it move downwards while replacing the previous pixels with the original grey image.
Thanks for the help! Appreacite it!
  1 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 2 月 23 日
I answered a similar question in the past. Just you have to adjust the pause time. Currently, I could not find the link to the question. If you are interested, please see my answer.
read image
imshow
looop
loop
ractangle
clear ractangle
pause(adjust)
end
end

サインインしてコメントする。

回答 (1 件)

Tarunbir Gambhir
Tarunbir Gambhir 2021 年 3 月 23 日
According to my understanding, you could use a for loop with a pause function to satisfy your requirements. It is a very crude, but simple way to do it. You can use this code to start with:
I = imread('baby.jpg');
for x=linspace(1,size(I,1)-size(I,2),50)
ind = round(x);
I_disp = 128*ones(size(I),'uint8');
I_disp(ind:ind+size(I,2),:,:) = I(ind:ind+size(I,2),:,:);
imshow(I_disp);
pause(1/100);
end
Note that you can optimize on this approach. This is just to give you an idea on how you can proceed. There might be some more efficient ways that can give you the same result.

カテゴリ

Help Center および File ExchangeModify Image Colors についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by