Save data from cycle into one table
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Hello, I have a code where the aotput is x and y, but I would like to store this data into one table or varieble. Problem is, that it gives me data only in one cyklus and it gives me it 15 times the same data, and than for h=2 it gives me 14 times the same value .. and so on
I would like to get one x and y from every loop and save it in one table or whatever, so after the code is ended, I would like to have everything in one place, if you understand. Now it gives me separately for every loop.
Thank you so much
채택된 답변
Image Analyst
2022년 11월 12일
x and y are the locations of all the white pixels in the image. There will likely be tens of thousands of values in each vector. Did you want the x and y of the blob centroid(s) instead?
What if you just stored the x and y in a cell array
ca{h, 1} = x;
ca{h, 2} = y;
Not sure why you have a loop within a loop but maybe you want i instead of h in the lines of code above.
Can we run your code with the demo that ships with MATLAB, rhinos.avi, or do we need your specific video to be attached?
댓글 수: 8
Eliska Paulikova
2022년 11월 13일
Well we can try it, because I do not know what to do next.
Yes I have two loops because I need to apply the segmentation and this was only way I can do it, because I do not have so much experience with matlab.
We can try it, but use the demo, it will work, but you do not see the result I need. But never mind, I only want to solve the problem with many datas in one cycle and how to save the data.
Thank you for helping me
Eliska Paulikova
2022년 11월 13일
As you can see, if I do for example regionprops(BW,"centroid")
it gives me this ... but like 15 times the same table ...

I don't know what you want. You just say you want the x and y coordinates of the segmented image. This is a classic XY Problem.
I told you how do get x and y for all white pixels in the segmented image. But since you came back I presume that is not what you wanted. You also got the centroids but I don't understand your pictures. Centroids are a 2 element vector, not a 5 by 1 vector. You have two structures, each with a field called Centroid but it has only one number in it. I don't know how you got those. What you should do is
props = regionprops(BW, 'Centroid');
xyCentroids = vertcat(props.Centroid)
So let's say that you are able to do whatever it is that you think you want (finding all x,y or just the x,y of the blob centroids, or whatever). Then what? What will you do with that information? Why do you even care about measuring it?
Also, please explain your thinking about why you have a whilte loop inside a for loop inside a while loop instead of a single for loop over the number of frames
for h = 1 : 2000 : vid.NumFrames
Eliska Paulikova
2022년 11월 13일
You are right I change it, now I have while cycle and for cycle .. I also get the x and y values.
Now the problem is, that I getting this data according to image segmentation, So if the segmentation is not good, it gives me NaN ... and I can to save it into table, because there is no value.
Image Analyst
2022년 11월 13일
OK, so you need to improve your segmentation algorithm if you think it's really there but your current algorithm is not finding it.
Eliska Paulikova
2022년 11월 13일
Thank you, when when I did it.
How can I store all this value from every cycle into one table. Because I will get many values but only for one cycle. I would like to store them together.
You can ask regionprops for a table. Then you can append the table for this frame to the growing master table.
thisTable = regionprops('table', BW);
if frameNumber == 1
masterTable = thisTable;
else
masterTable = [masterTable; thisTable];
end
Eliska Paulikova
2022년 11월 14일
편집: Eliska Paulikova
2022년 11월 14일
Thank you so much, I appreciate it a lot
It helped
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Image Preview and Device Configuration에 대해 자세히 알아보기
참고 항목
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)
