이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
How can I color certain part of video (suppose hand) and detect the color using color thresholding?The latter part is fine . Plz help me on this.
조회 수: 2 (최근 30일)
이전 댓글 표시
I want to know how to color certain region in video in matlab
댓글 수: 2
Aarach Sap
2021년 9월 14일
I want to color the two hands to different color . Is it possible in matlab?
답변 (1개)
Image Analyst
2021년 9월 13일
See my attached demo where I find a green Sharpie in the video. Adapt as needed.
댓글 수: 17
Aarach Sap
2021년 9월 14일
Thank you! I have already checked your demo.I would like to color two hands differently and track the color.
Is it possible?Plz help me.
Image Analyst
2021년 9월 14일
Yes it's possible. Just do your image segmentation to get two blobs (hands). Then label them with bwlabel() and then use label2rgb() to apply colors. Use regionprops(binaryImage, 'Centroid') to track the centroids.
% Label each blob with 8-connectivity, so we can make measurements of it
[labeledImage, numberOfBlobs] = bwlabel(binaryImage, 8);
% Apply a variety of pseudo-colors to the regions.
coloredLabelsImage = label2rgb (labeledImage, 'hsv', 'k', 'shuffle');
% Display the pseudo-colored image.
imshow(coloredLabelsImage);
% Get all the blob properties. Can only pass in originalImage in version R2008a and later.
blobMeasurements = regionprops(labeledImage, originalImage, 'all');
numberOfBlobs = size(blobMeasurements, 1);
Aarach Sap
2021년 9월 15일
Thank you for your time! I also noticed label2rgb() is there to apply colors. However, there is still error on regionprops section.
i.e.,blobMeasurements = regionprops(labeledImage, originalImage, 'all');
Actually, my originalImage does not include colored hands,both are same as skintone. Is it bcoz of that?
Image Analyst
2021년 9월 15일
@Aarach Sap, it depends on what youre measuring. Show me your line of code for regionprops(). If you're measuring shape only things then you don't need the gray scale image "originalImage". If you're measuring intensity things, like MeanIntensity, then you'll need to include a gray scale image (usually uint8). You didn't pass in the full RGB color image for originalImage, did you? Because that would be a huge mistake.
Also, you forgot to read the posting guidelines
which means you did not know that you need to include your image and code, as well as the complete error message. If you need more help, please attach them after reading the link above.
Aarach Sap
2021년 9월 16일
편집: Aarach Sap
2021년 9월 16일
Sorry, for making you in trouble and Thank you! I am able to do regionprops from your code. Here is the code. I got the centriods of all region of interest. However, I want to track the centriods according the colors shown not by area. As I am using in video the area of region of interest may change, so I want to track the same color and get the centriod.
Image Analyst
2021년 9월 16일
@Aarach Sap, you forgot to attach the A.png image. Also, this program just looks at a single image, not multiple frames of a video, and does no tracking.
Plus, I have not delivered a full blown tracking app. I track just one blob in the video, not multiple. Having multiple blobs increases the complexity enormously if it's to take into account blobs entering and leaving the fielw of view, blobs overlapping, blobs changing shape or color, etc.
Aarach Sap
2021년 9월 17일
The program I attached is only for Image. Any image of a person showing hands can be used. However, I want to apply for video. Is it possible to fill different colors to different blobs? or Can we set the colors in label2rgb or sth like that. I am still not getting to the point. Plz suggest me!
Image Analyst
2021년 9월 17일
- "Is it possible to fill different colors to different blobs?" Yes, with bwlabel() and label2rgb().
- "Can we set the colors in label2rgb or sth like that?" Yes, you can specify the colors used to label the blobs, like if you want jet instead of hsv, do
% Apply a variety of pseudo-colors to the regions.
coloredLabelsImage = label2rgb (labeledImage, 'jet');
Aarach Sap
2021년 9월 22일
Thank you for your reply! But this method change the colors of two blobs i.e.hands, in various colors in different frames of a video. So it is not possible track those blobs by coloring them. Actually, I need the centriod of blobs, which I already get it and can display it. Why is it difficult to write those points( eg.this point is for left blob)? Is there any other way? I thought coloring will do but actually dont. Plz suggest me if there are any idea regarding this.
Image Analyst
2021년 9월 22일
You can certainly detect two colored objects in a frame, and can produce a binary image (mask) from them. This is usually done by color segmentation (thresholding some image). Then you can detect the centroids of the blobs using regionprops(). You can log those centroids to an array. But all of that is done by what I said -- thresholding and assignment -- it's not done by coloring the blobs. However, once the hands have been detected (mask generated) and tracked (centroid locations logged), it's possible to colorize the hands (e.g. left=blue, and right=red) using label2rgb(). That colorizing process is not called "tracking". The tracking was done when you thresholded, found the centroids, and saved their location, NOT by colorizing the blobs after you found them.
Aarach Sap
2021년 9월 24일
I dont have two colored objects. I have only one color i.e. skin color of hands . I want to track the centriod of two hands and write this centrod is for left hand and other is for right hand. I understand what you explain. Thank you for that.
Image Analyst
2021년 9월 24일
So you have two colored objects that have roughly the same color. You can detect both of those with the same color segmentation or motion segmentation algorithm. Then call
mask = bwareafilt(mask, 2);
to extract the two largest blobs, which should be the hands. Then do
props = regionprops(mask, 'Centroid');
xy = vertcat(props.Centroid);
to get the centroid of each hand.
Aarach Sap
2021년 9월 27일
Thank you Image Analyst for the continuous response! I really appreciate your help. I have tried this one.
mask = bwareafilt(mask, 2);
[labeledImage, numberOfBlobs] = bwlabel(mask);
%for the first blob 1
blobMeasurements= regionprops(labeledImage==1, 'BoundingBox', 'Centroid','Orientation');
Centriod_of1= vertcat(blobMeasurements.Centroid);
However, if the hand is crossed then it will take other hand as first blob why? I just want to track the hand movement.
Image Analyst
2021년 9월 27일
Tracking is a difficult thing. There are problems with tracked objects overlap, or enter or leave the field of view. I did not write a full, turnkey tracking app that handles all kinds of situations. You can search the internet for tracking apps. I know I listed a bunch of such tracking websites here this summer so you can look for that list.
Aarach Sap
2021년 9월 29일
Yes, tracking is difficult. Anyways thank you for your earlier suggestions. I learned so many things. Do you suggest any best tracking website?
Image Analyst
2021년 9월 29일
@Aarach Sap We use the tracking program from Noldus. I believe it's the best out there. It's expensive but it may save you much time over developing it yourself.
Other, cheaper tracking programs are listed in my Answer here:
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Processing and Computer Vision에 대해 자세히 알아보기
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)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)