hi I have error message in matlab 2017
reference to non-existent field 'solidity'
Error in Tumor(line denisty={stats.solidity};
how can I add reference
what did i miss ?

 채택된 답변

Walter Roberson
Walter Roberson 2019년 4월 17일

0 개 추천

If stats was created by calling regionprops, then the field name should be Solidity with a capital S.

댓글 수: 13

Mohamed Nasr
Mohamed Nasr 2019년 4월 17일
you mean I will edit
stats.solidity
to
stats.Solidity with Capital S Letter on all my code ?!
Mohamed Nasr
Mohamed Nasr 2019년 4월 17일
편집: Mohamed Nasr 2019년 4월 17일
clear clc img=imread('brain1.jpg'); img1=rgb2gray(img); bw=imbinarize(img1 , 0.7); %Thresholding value if less than 0.7 color is black ,if morr than 0.7 color is white label=logical(bw); %area of tumor stats =regionprops(label,'Solidity','Area'); %healthy region denisty={stats.Solidity}; area={stats.Area}; high_dense_area = denisty>0.5 ; %Area of tumor max_area=max(area(high_dense_area)); %max area tumor_label=find(area==max_area); %place of tumor tumor = ismember(label,tumor_label); s=strel('square',5); tumor=imdilate(tumor,s); figure; subplot(1,3,1);imshow(img);title('Brain' ); subplot(1,3,2);imshow(tumor);title('Tumor alone' );
I had to make some guesses about exactly where the line breaks are when I fixed the format of your code to make it readable.
Yes, {stats.Area} and {states.Solidity}
Mohamed Nasr
Mohamed Nasr 2019년 4월 17일
Solidity error was solved thanks alot but there still another error I copied all my code to see it This is the last error
Mohamed Nasr
Mohamed Nasr 2019년 4월 17일
Undefined operator '>' for input arguments of type 'cell'.
Error in Tumor (line 10) high_dense_area = denisty > 0.5 ; %Area of tumor
[stats.Area] and [stats.Solidity]
clear
clc
img=imread('brain1.jpg');
img1=rgb2gray(img);
bw=imbinarize(img1 , 0.7); %Thresholding value if less than 0.7 color is black ,if morr than 0.7 color is white
label=logical(bw); %area of tumor
stats =regionprops(label,'Solidity','Area'); %healthy region
denisty={stats.Solidity};
area={stats.Area};
high_dense_area = denisty > 0.5 ; %Area of tumor
max_area=max(area(high_dense_area)); %max area
tumor_label=find(area==max_area); %place of tumor
tumor = ismember(label,tumor_label);
s=strel('square',5);
tumor=imdilate(tumor,s);
figure;
subplot(1,3,1);imshow(img);title('Brain' );
subplot(1,3,2);imshow(tumor);title('Tumor alone' );
sorry I paste the code from mobile now this is the code as matlab
[stats.Area] and [stats.Solidity] are Capital Letters now but still have the next error
Undefined operator '>' for input arguments of type 'cell'.
Error in Tumor (line 10)
high_dense_area = denisty > 0.5 ; %Area of tumor
You did not change the { } to [ ] in assigning to denisty and area
denisty = [stats.Solidity];
area = [stats.Area];
Mohamed Nasr
Mohamed Nasr 2019년 4월 17일
thank you the code without any errors now but the result for processing this brain tumor image is a black imageaaa.JPG
Mohamed Nasr
Mohamed Nasr 2019년 4월 17일
aaa1.JPG
this is the correct result as it assumed to appear on the right picture
Please attach the brain image by itself so we can test.
Mohamed Nasr
Mohamed Nasr 2019년 4월 17일
c.JPG
the original image

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

추가 답변 (2개)

Mohamed Nasr
Mohamed Nasr 2019년 4월 18일

0 개 추천

clear all
clc
close all
img=imread('brain2.jpg');
bw=imbinarize(img , 0.9); %Thresholding value if less than 0.7 color is black ,if morr than 0.7 color is white
label=logical(bw); %area of tumor
stats =regionprops(label,'Solidity','Area'); %healthy region
denisty=[stats.Solidity];
area=[stats.Area];
high_dense_area = denisty > 0.5 ; %Area of tumor
max_area=max(area(high_dense_area)); %max area
tumor_label=find(area==max_area); %place of tumor
tumor = ismember(label,tumor_label);
s=strel('square',4);
tumor=imdilate(tumor,s);
figure;
subplot(1,3,1);imshow(img,[ ]);title('Brain' );
subplot(1,3,2);imshow(tumor,[ ]);title('Tumor alone' );
[B,L]=bwboundaries(tumor,'noholes');
subplot(1,3,3);imshow(img,[])
hold on
for i=1:length(B)
Plot(B{i}(:,2),B{i}(:,1),'Y','lenewidth',1.45)
end
title('Detected image')
hold off
this is my code dosenot run correctly what i miss in this code and it is one of optimal image attach the vidio with it
https://www.youtube.com/watch?v=UeFRo7uALhM&fbclid=IwAR1JmjjnCB3rnLYSiWwIQ1inxVJPA8WpwVUCJ-ncEy5MpKzWBHHe9jEWVjs

댓글 수: 13

You have
label=logical(bw);
The maximum possible value for that array is 1, corresponding to true.
You calculate tumor_label as the indices of (all of) the areas that have (the same) maximum area. It will not usually be 1.
You have
tumor = ismember(label, tumor_label)
remember that label is a bunch of true and false values, so it is likely that none of them are going to equal the index(es) you found.
You should consider
label = bwlabel(logical(bw));
Mohamed Nasr
Mohamed Nasr 2019년 4월 20일
I change label=ligical(bw); To label = bwlabel(logical(bw)); And i have this error message
Mohamed Nasr
Mohamed Nasr 2019년 4월 20일
Expected input number 1, BW, to be two-dimensional.
Error in bwlabel (line 65)
validateattributes(BW, {'logical' 'numeric'}, {'real', '2d', 'nonsparse'}, ...
Error in tumor2 (line 6)
label = bwlabel(logical(bw)); %area of tumor
its work on only one picture even after the last change to the code
bw=imbinarize(img,0.9); %Thresholding value if less than 0.7 color is black ,if morr than 0.7 color is white
if i change 0.9 to 0.7 or less or more it doesnt work at all on any picture
i didnt get clearly what you mean but i think you explain that logical value should be only one
of two values true or false 1 or 0 yes or no
and that make my ability to but values more than 1 is none
so how could i solve this mess on my code i have to explain this code with many other issues
in the university to my prof and many things depend on it when it work on my reseach
i realy want the code work correctly on all tumor photos and i want understand it
Mohamed Nasr
Mohamed Nasr 2019년 4월 20일
this link contain all the original photos that was tested by the programer on the video
you should found
And Thank you Walter Roberson for Everything
bw=imbinarize(img,0.7); %Thresholding value if less than 0.7 color is black ,if morr than 0.7 color is white
I change (img,0.9) to (img,0.7)
and change denisty to 0.2
high_dense_area = denisty > 0.2 ; %Area of tumor
and i got the results for 4 photos work correctly
Mohamed Nasr
Mohamed Nasr 2019년 4월 20일
57364777_410895686375401_2721482963136020480_n.jpg
Mohamed Nasr
Mohamed Nasr 2019년 4월 20일
57486451_1231284023715244_1468735715511631872_n.jpg
Is there still and active question here?
Mohamed Nasr
Mohamed Nasr 2019년 4월 21일
Yes I still dont know why this code didnt work with all brain tumor images 20 image only 6 work and other images when I run the code I got this error message
Mohamed Nasr
Mohamed Nasr 2019년 4월 21일
Expected input number 1, BW, to be two-dimensional. Error in bwlabel (line 65) validateattributes(BW, {'logical' 'numeric'}, {'real', '2d', 'nonsparse'}, ... Error in tumor2 (line 6) label = bwlabel(logical(bw)); %area of tumor
Code attached.

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

Mohamed Nasr
Mohamed Nasr 2019년 5월 21일

0 개 추천

Thanks alot really for your patient and your support

카테고리

도움말 센터File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

제품

질문:

2019년 4월 17일

답변:

2019년 5월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by