Let's say I have an image called A and another constant image of the same size how do I get the set union of those 2 images : the union should be of the same size as image A
Note: when I use union function it gives me an error (A and B must be vectors or 'rows' must be specified.)

 Accepted Answer

Matt J
Matt J on 28 Oct 2013
Edited: Matt J on 28 Oct 2013
the union should be of the same size as image A
Then you have an unconventional definition of a "union". There's no reason they should be the same size. Possibly you want to do a pixel-wise or() operation?
Union = A|B
Otherwise please clarify.

5 Comments

John Snow
John Snow on 28 Oct 2013
Edited: John Snow on 28 Oct 2013
Union = A|B made the result (all white) instead of the union im looking for.
Here is an example :assuming images B and A are the same size I would like C to have the same size as well
Matt J
Matt J on 28 Oct 2013
Edited: Matt J on 28 Oct 2013
I can't tell from these images what the relationship between C, A and B is supposed to be. Maybe you mean C=A+B?
The intended operation looks like it's supposed to be independent for each pixel. Can you describe in words for a fixed pixel (i,j) how C(i,j) is generated from A(i,j) and B(i,j)?
lets say B pixels have a constant value of 0.5 I want all pixels in A image whose pixels are less than 0.5 to become 0.5 for example if A is [ 0.3 0.2 0.6 0.8] C will be [ 0.5 0.5 .6 0.8]
C=max(A,0.5);
Thank you very much this works good

Sign in to comment.

More Answers (1)

Maybe you mean something like this:
% Find dark pixels.
binaryImage = skeletonImage < 50; % Or whatever intensity you want.
% Replace dark pixels with pixels from image B.
C_Image = skeletonImage; % Initialize
C_Image(binaryImage) = B_Image(binaryImage); % Replace.

1 Comment

This works ok but i think the "C=max(A,0.5);" command is easier from the other anser is easier but thank you very much for your answer

Sign in to comment.

Categories

Find more on Images in Help Center and File Exchange

Asked:

on 28 Oct 2013

Commented:

on 28 Oct 2013

Community Treasure Hunt

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

Start Hunting!