How to eleiminate the black background and retain the region of interest in my image?

조회 수: 1 (최근 30일)
Hai,I have an image of the fist which is captured with a black background.The image is an IR (infra red) image captured with a webcamera converted to work in IR .The picture has captured the veins under the skin.What i want to do is just retain the fist and get rid of the surrounding black area.As in my region of interest is just the fist.How do i do this ? I have done something but am just getting a black image for this:
a=imread('1.jpg');
figure;
imshow(a);
b=rgb2gray(a);
figure;
imshow(b);
[j,k]=size(b);
for g=1:j
for f=1:k
if b(j,k)>0.06
c(j,k)=0;
else
c(j,k)=1;
end
end
end
figure,imshow(c);
this is the image: http://lastqueen21.blogspot.com/2011/04/image.html Can somebody please tell me the code for what I want ?? Thank you so much :(

채택된 답변

Sean de Wolski
Sean de Wolski 2011년 4월 22일
I would do this using my shrinkWrap function:
I = imread('answers421.jpg'); %answers421.jpg is your image
M = shrinkWrap(rgb2gray(I)); %map of hand
IjustHand = bsxfun(@times,uint8(M),I); %apply map to rgb image
imshow(IjustHand) %view
shrinkWrap is available here: FEX shrinkWrap
EDIT to show result:

추가 답변 (5개)

Khadeejah
Khadeejah 2011년 4월 22일
<<
a=imread('1.jpg');
figure; imshow(a);
b=rgb2gray(a);
figure; imshow(b);
[j,k]=size(b);
for g=1:j
for f=1:k
if b(j,k)>0.06
c(j,k)=0;
else c(j,k)=1;
end
end
end
figure,imshow(c);
>>
  댓글 수: 2
Sean de Wolski
Sean de Wolski 2011년 4월 22일
<<url_to_a_web_address_with_your_image>>
www.uploadhouse.com is a good free uploading site that allows for direct links.
Khadeejah
Khadeejah 2011년 4월 22일
hai sean ..can u see i ve edited the main question ...bt ill put it here as well :
<<http://lastqueen21.blogspot.com/2011/04/image.html>>

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


Khadeejah
Khadeejah 2011년 4월 22일
is this right the way I ve put it ?

Khadeejah
Khadeejah 2011년 4월 23일
hai sean ...! :D thnaks for your answer . I have downloaded this m file .Am very new to this ..so after downloading, I extract it and do what ? ASin should i store it in a folder in matlab ? which 1 ?

Khadeejah
Khadeejah 2011년 4월 23일
i downloaded the file and saved it in work folder and did this program that u mentioned. a=imread('1.jpg'); figure(1); imshow(a); b=shrinkWrap(rgb2gray(a)); IjustHand=bsxfun(@times,uint8(M),a); imshow(IjustHand); >
this is the error am getting, : Error in ==> test at 4 b=shrinkWrap(rgb2gray(a));
So what do i do now :( ?

Khadeejah
Khadeejah 2011년 4월 23일
i did the set path and installed the file . And did the code u mentioned This is the error am getting:
??? Error: File: C:\shrinkWrap\shrinkWrap.m Line: 89 Column: 5 Illegal use of reserved keyword "else".
Error in ==> test at 5 c=shrinkWrap(b);
  댓글 수: 1
Sean de Wolski
Sean de Wolski 2011년 4월 25일
What version of ML do you have? Did you change ANYTHING when you downloaded it? It's in working form, to the best of my knowledge, and others have used it so I'm guessing there's something quirky with how you downloaded it.

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

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by