COPY_PASTE_CVIP
copy_paste_cvip() - Copy a subimage from one image and paste to the same or another image.
Contents
SYNTAX
outImage = copy_paste_cvip( srcImage, destImage, startLocs, sizeSubimg, destLocs, transparent)
Input Parameters include :
- srcImage - Source image to copy the subimage. 1-band input image of MxN size or 3-band input image of MxNx3 size.
- destImage - Destination image for pasting.
- startLocs - Starting point of upper-left corner of the subimage on srcImage. A vector of length 2 (Eg. [1 1]). startLocs(1): Row value startLocs(2): Column value
- sizeSubImg - Size of desired subimage. A vector of length 2. (Eg. [1 1]). sizeSubImg(1): height sizeSubImg(2): width
- destLocs - Starting point of upper-left corner of the destImage area to paste the subimage. A vector of length 2 (Eg. [1 1]). destLocs(1): Row value destLocs(2): Column value
- transparent - Whether the paste is transparent or not (1 or 0).
Output Parameter includes :
- outImage - Output image after copy-paste operation.
DESCRIPTION
The function copies a subimage from the sourceImage and pastes it to the destinationImage.It is designed for the cross-image copy-paste,but it also works for copy-paste within the same image,which is indicated by making srcImage == destImage.If the subimage is too large,the size will be adjusted automatically so the subimage can be successfully copied from the srcImage and pasted to the destImage. If srcImage is 1-band image and destImage is 3-band image,then srcImage is made as 3-band image by copying same band information to other bands before pasting to destImage.In other case,if srcImage is 3-band image and destImage is 1-band image,only first band of scrImage is pasted to destImage.
REFERENCE
1. Scott E Umbaugh. DIGITAL IMAGE PROCESSING AND ANALYSIS: Applications with MATLAB and CVIPtools, 3rd Edition.
EXAMPLE
% Read image I1 = imread('cam.bmp'); %source image I2 = imread('butterfly.tif'); %destination image % Start locs start_locs = [10 5]; % size sub image size_subimage = [150 200]; % Destination locs dest_locs = [64 64]; % transparent transparent = 1; % call function O = copy_paste_cvip( I1, I2,start_locs,size_subimage,dest_locs,transparent); % Display input image figure;imshow(I1);title('Input Image1'); figure;imshow(I2);title('Input Image2'); % Display output image figure; imshow(O);title('Output Image');
CREDITS
Author: Norsang Lama, April 2017
Copyright © 2017-2018 Scott
E Umbaugh
For updates visit CVIP Toolbox Website