이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
hi chandra, what should i do if i want to display the intersection portion.
댓글 수: 1
Image Analyst
2011년 12월 6일
There is no context for this question. You should reply to your other thread and delete this one, or at the very least, put in a link to the other thread that you split off from.
채택된 답변
Chandra Kurniawan
2011년 12월 6일
Hello,
Sorry for waiting.
Here the code :
array = uint8(intersection);
for row = size(intersection,1) : -1 : 1
if ~any(find(intersection(row,:)))
array(row,:) = [];
end
end
for col = size(intersection,2) : -1 : 1
if ~any(find(intersection(:,col)))
array(:,col) = [];
end
end
imshow(array);
댓글 수: 19
David Young
2011년 12월 6일
It would be better to edit this into the previous answer, so as to avoid proliferation of questions.
k.v.swamy
2011년 12월 6일
i have written the below code can u modify that
clc;
clear all;
close all;
I = double(imread('cameraman.tif'));
J = double(I);
J(115:155, 192:204) = 50;
imshow(uint8(I)),figure,imshow(uint8(J))
xcount=0;ycount=0;
l=length(I);
s=zeros(l,l)
for i=1:l
xcount=xcount+1;
for j=1:i
if I(i,j)==J(i,j)
ycount=ycount+1;
s(xcount,ycount)=I(i,j);
elseif I(i,j)~=J(i,j)
s(xcount,ycount)=0;
end
end
end
figure,imshow(s)
Chandra Kurniawan
2011년 12월 6일
Here, I modify the code from my last own code
clear; clc;
I = double(imread('cameraman.tif'));
J = double(I);
J(115:155, 192:204) = 50;
intersection = abs(J - I);
array = uint8(intersection);
for row = size(intersection,1) : -1 : 1
if ~any(find(intersection(row,:)))
array(row,:) = [];
end
end
for col = size(intersection,2) : -1 : 1
if ~any(find(intersection(:,col)))
array(:,col) = [];
end
end
imshow(uint8(I)); title('Image A');
figure, imshow(uint8(J)); title('Image B');
figure, imshow(uint8(array)); title('Intersection A and B');
k.v.swamy
2011년 12월 6일
but we need to get the intersection portion,what v r getting is the area which is not common to the two images.if u dont mind can u look at the code what i have written.
k.v.swamy
2011년 12월 6일
while i was executing that code it is going to a infinite loop.
Chandra Kurniawan
2011년 12월 6일
Why did you write 'for j = 1 : i'?
Did you mean 'for j = 1 : l'??
It makes your final size of 's' becomes '256 x 32896'.
The size of 's' might be 256 x 256, right??
Chandra Kurniawan
2011년 12월 6일
I modified it once again.
Maybe this is what you mean??
clear; clc;
I = double(imread('cameraman.tif'));
J = double(I);
J(115:155, 192:204) = 50;
imshow(uint8(I)),
figure, imshow(uint8(J));
xcount = 0; ycount = 0;
l = length(I);
s = zeros(l, l);
for i = 1 : l
xcount = xcount + 1;
for j = 1 : l
if I(i,j) == J(i,j)
ycount = ycount + 1;
%s(xcount, ycount) = I(i,j);
s(i,j) = I(i,j);
elseif I(i,j) ~= J(i,j)
%s(xcount,ycount)=0;
s(i,j) = 0;
end
end
end
figure, imshow(uint8(s));
k.v.swamy
2011년 12월 6일
yes i got your statement.is it the right way of writing the code.can u suggest any modification in that so that i can continue with that.
Chandra Kurniawan
2011년 12월 6일
So, my last modified code is right??
Your code works well. So, you can ignore writing 'xcount = 0;' and 'ycount = 0;'.
You don't need to use this variable as a element counter.
You just need i and j.
So, I replaced '%s(xcount, ycount) = I(i,j);' with 's(i,j) = I(i,j);'
And '%s(xcount,ycount)=0;' with 's(i,j) = 0;'
You ask me for any modification so that you can continue..
So, what will you do with your next step??
Chandra Kurniawan
2011년 12월 6일
Does it clear for you? :)
k.v.swamy
2011년 12월 6일
fine chandra,sorry for the delay as i went outside.what should be the limits of i and j.i think i varies from 1 to 256 and j varies from 1 to 256.pl reply.
Chandra Kurniawan
2011년 12월 6일
Yes, of course.
Because i represents image height [row] and j represent image width [column].
So, both of value are from 1 to 256 as height and width of cameraman.tif
k.v.swamy
2011년 12월 6일
iam getting the common area,but iam unableto show the non intersection region.
k.v.swamy
2011년 12월 6일
yes chandra workin fine iam pasting the code also
clc;
clear all;
close all;
I = double(imread('cameraman.tif'));
J = double(I);
J(115:155, 192:204) = 50;
imshow(uint8(I)),figure,imshow(uint8(J))
l=length(I);
for i=1:256
for j=1:256
if I(i,j)==J(i,j)
s(i,j)=I(i,j);
elseif I(i,j)~=J(i,j)
s(i,j)=255;
end
end
end
figure,imshow(uint8(s))
pl hav a look and giv me reply.
Chandra Kurniawan
2011년 12월 6일
What does 'non intersection region'??
Can you tell me which area that you mean??
Yes, I have saw your code.
Why do you fill the intersection area with white pixels [255]?
It seem good if filled with black pixels.
k.v.swamy
2011년 12월 6일
s it is workin.as i have taken s(i,j)=255; iam able to recognize the intersection area.
k.v.swamy
2011년 12월 7일
hi chandra,its me k.the code which we have written works if the images are of same size.how to write the code for two different images.
Chandra Kurniawan
2011년 12월 7일
Hi, k
I think it is impossible.
You can only do matrix subtraction if both of dimension and size are same.
If we know about matrix concept, if we have matrix A [p x q] and B [r x s], subtraction matrix A with matrix B can be occur only is p == r and q == s.
So, you cannot perform it with different size of two matrices.
k.v.swamy
2011년 12월 7일
yes i do agree with the answer,but in my assignment iam given two sets of images for which i have to find the intersection
https://picasaweb.google.com/103266594409982679463/ImagesSet1?authuser=0&feat=directlink
https://picasaweb.google.com/103266594409982679463/IMAGESSET2?authuser=0&feat=directlink
i hav given u the links and i have written the code like
clc;
clear all;
close all;
I = double(imread('work.jpg'));
J = double(imread('work1.jpg'));
imshow(uint8(I)),figure,imshow(uint8(J))
l=length(I);
for i=1:l
for j=1:l
if i>1200
i=1200
end
if I(i,j)==J(i,j)
s(i,j)=I(i,j);
elseif I(i,j)~=J(i,j)
k(i,j)=I(i,j);
end
end
end
figure,imshow(uint8(k))
pl verify for once
추가 답변 (1개)
Chandra Kurniawan
2011년 12월 7일
1 개 추천
I got little confused with your question.
Let me pick one picture.

Then which another picture will be intersected with that image??
댓글 수: 3
k.v.swamy
2011년 12월 8일
If the image u have taken is from set 1 then take another image from set 2 and I assume image from set 1 has work and from set2 as work1
Pls verify the code does it work
Waiting for u r reply
Thank u
k.v.swamy
2011년 12월 8일
chandra if u get any clue pl reply me.
k.v.swamy
2011년 12월 9일
hi chandra,can u pl look at my problem and giv me reply.
카테고리
도움말 센터 및 File Exchange에서 Image Arithmetic에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
