From: Luigi Torres on
I'm a little confused about doing a particular thing in matlab. I have the following picture.

http://s287.photobucket.com/albums/ll149/herbozo2003/?action=view&current=untitled.jpg

Now I want to get rid of the black background, and be able to reduce that pic and paste it onto another picture. But I am having trouble getting rid of the black background. Can someone pls help me with this I would apreciate it.

Thank you

Luigi
From: Jan Simon on
Dear Luigi!

> Now I want to get rid of the black background, and be able to reduce that pic and paste it onto another picture. But I am having trouble getting rid of the black background. Can someone pls help me with this I would apreciate it.

If you had troubles, show us the code and describe the troubles with some details, e.g. error messages. It is always easier to assist, then to solve your whole problem.

Jan
From: ImageAnalyst on
Luigi:
Perhaps this will be instructive:
Be sure to join any lines split into two by the newsreader.

clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear all; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
fontSize = 18;

% Read in image.
filename = 'C:\SomePath\luigi.jpg';
rgbImage = imread(filename);
% Convert to gray.
imageArray = rgb2gray(rgbImage);
subplot(2, 2, 1);
imshow(imageArray, []);
title('Original Image', 'FontSize', fontSize);
set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.

[rows columns numberOfColorBands] = size(imageArray);
% Get our destination image.
destinationImage = imread('concordorthophoto.png');
% Let's resize it so they're the same size
destinationImage = imresize(destinationImage, [rows columns]);
subplot(2, 2, 2);
imshow(destinationImage, []);
title('Destination Image Before Pasting', 'FontSize', fontSize);

% Paste into destination image.
pixelsToPaste = imageArray > 0;
destinationImage(pixelsToPaste(:)) = imageArray(pixelsToPaste(:));
subplot(2, 2, 3);
imshow(destinationImage, []);
title('Destination Image After Pasting', 'FontSize', fontSize);


From: Luigi Torres on
Hi simon, this is my problem:

%Reading target image
targetI = imread(targetfilename);
imagesc(targetI);

% get some coordinates from the target image
[targetx,targety] = ginput(4);

%Reading source image
sourceI = imread(sourcefilename);
imagesc(sourceI);

% get some coordinates from the source image
[sourcex,sourcey] = ginput(4);


% make them integers ---- source
sourcex = round(sourcex); sourcey = round(sourcey);

% make them integers ---- target
targetx = round(targetx); targety = round(targety);


TFORM = cp2tform([sourcex,sourcey],[targetx,targety],'affine');

%get out a small subimage
subimg = sourceI(sourcey(1):sourcey(3),sourcex(1):sourcex(3),:);
figure;
imagesc(subimg)
axis equal

%transformed image
newimage = imtransform(subimg,TFORM);

%creating mask ---------------------- I'm stuck hereeeeeee
mask = ones(size(newimage));

% newimage is the image in the link I provided. I need to get rid of that black
% background, reduce the image and paste it in the target image which is called
% targetI.

I would really apreciate your help since I'm not an expert in matlab, and I believe you have more experience on it.

Thank you

Luigi


"Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <hpdndb$fmu$1(a)fred.mathworks.com>...
> Dear Luigi!
>
> > Now I want to get rid of the black background, and be able to reduce that pic and paste it onto another picture. But I am having trouble getting rid of the black background. Can someone pls help me with this I would apreciate it.
>
> If you had troubles, show us the code and describe the troubles with some details, e.g. error messages. It is always easier to assist, then to solve your whole problem.
>
> Jan