How to assign zero pixel location of one image to other

조회 수: 1 (최근 30일)
Jim
Jim 2011년 9월 22일
Hi,
I need to assign zero pixel location of one image to the zero pixel location of other
Can anybody suggest something about this
Thanks in advance
  댓글 수: 2
David Young
David Young 2011년 9월 22일
Your question is not clear: please can you explain what you mean, perhaps with a small example of the images before and after assignment.
Jim
Jim 2011년 9월 22일
Hi,
thank you for ur reply
I am giving a example here for clear understanding
suppose image1 having pixels like this
[1 2 0;3 0 1;0 7 5] and
image2 having pixels like this
[2 2 3;5 5 1;7 7 5]
I need to replace the pixel values with zero in image1 with the values of the same pixel location in image2
that is in row 1 of image1 0 must be replaced by 3 which is in the same pixel location in image 2
i,e after replacing image1 must become like [1 2 3;3 5 1;7 7 5]
But i have two images with size 256*256
I stored all the locations of image1 with pixel value 0 in an array
and now I need to replace the pixel values with zero in image1 with the values of the same pixel location in image2
Thanks in advance

댓글을 달려면 로그인하십시오.

답변 (2개)

Image Analyst
Image Analyst 2011년 9월 22일
Do you mean like you want image2 to be zero in the same places that image1 is? Like this(untested):
image2(image1==0) = 0;
Please clarify.
  댓글 수: 2
Jim
Jim 2011년 9월 22일
Hi,
thank you for ur reply
I am giving a example here for clear understanding
suppose image1 having pixels like this
[1 2 0;3 0 1;0 7 5] and
image2 having pixels like this
[2 2 3;5 5 1;7 7 5]
I need to replace the pixel values with zero in image1 with the values of the same pixel location in image2
that is in row 1 of image1 0 must be replaced by 3 which is in the same pixel location in image 2
i,e after replacing image1 must become like [1 2 3;3 5 1;7 7 5]
But i have two images with size 256*256
I stored all the locations of image1 with pixel value 0 in an array
and now I need to replace the pixel values with zero in image1 with the values of the same pixel location in image2
Thanks in advance
Walter Roberson
Walter Roberson 2011년 9월 22일
z = image1 == 0;
image1(z) = image2(z);

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2011년 9월 22일
Try this:
image1 = [1 2 0;3 0 1;0 7 5]
image2 = [2 2 3;5 5 1;7 7 5]
pixelsToReplace = image1 == 0
image1(pixelsToReplace) = image2(pixelsToReplace)
  댓글 수: 1
Image Analyst
Image Analyst 2011년 9월 22일
You should note that I already showed you this concept in your nearly identical question: http://www.mathworks.com/matlabcentral/answers/16350-how-to-remove-pixels-in-an-image

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by