Paste new image to random locations

I want to read a set of images in a folder and paste a cropped part of another new image to random locations of each image. I used imfuse() function, but the cropped image only places at the upper left corner not in random locations.n How to do it for random locations?

답변 (1개)

KSSV
KSSV 2018년 6월 26일

0 개 추천

I = imread('peppers.png') ;
[J,rect] = imcrop(I) ;
[nx,ny,~] = size(I) ;
[nx1,ny1,~] = size(J) ;
%%place at random location
posx = randsample(nx1:nx-nx1,1) ;
posy = randsample(ny1:ny-ny1,1) ;
%place the cropped part
I(posx:posx+nx1-1,posy:posy+ny1-1,:) = J ;
imshow(I) ;

카테고리

도움말 센터File Exchange에서 Convert Image Type에 대해 자세히 알아보기

질문:

NC
2018년 6월 26일

답변:

2018년 6월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by