MATLAB: Copy a part of image to a dumthe image on specific pixel location

copy a blob on specific pixel location.Image Processing Toolbox

hay i have extracted a blob from an image and its pixelList using regionprops. now i want to copy this blob on a dummy image( equal to original image size) on pixel location of PixelList.is there an easy way to do this?

Best Answer

Well, the easier way is to ask for 'PixelIdxList' instead of 'PixelList'.
PixelIdxList = sub2ind( size(YourImage), PixelList);
Once you have PixelIdxList,
NewImage = 0 * YourImage; %same size and class
NewImage(PixelIdxList) = YourImage(PixelIdxList);