You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
reference to non-existent field solidity
2 views (last 30 days)
Show older comments
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 ?
Accepted Answer
Walter Roberson
on 17 Apr 2019
If stats was created by calling regionprops, then the field name should be Solidity with a capital S.
13 Comments
Mohamed Nasr
on 17 Apr 2019
you mean I will edit
stats.solidity
to
stats.Solidity with Capital S Letter on all my code ?!
Mohamed Nasr
on 17 Apr 2019
Edited: Mohamed Nasr
on 17 Apr 2019
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' );
Walter Roberson
on 17 Apr 2019
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.
Walter Roberson
on 17 Apr 2019
Yes, {stats.Area} and {states.Solidity}
Mohamed Nasr
on 17 Apr 2019
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
on 17 Apr 2019
Undefined operator '>' for input arguments of type 'cell'.
Error in Tumor (line 10) high_dense_area = denisty > 0.5 ; %Area of tumor
Walter Roberson
on 17 Apr 2019
[stats.Area] and [stats.Solidity]
Mohamed Nasr
on 17 Apr 2019
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
Walter Roberson
on 17 Apr 2019
You did not change the { } to [ ] in assigning to denisty and area
denisty = [stats.Solidity];
area = [stats.Area];
Mohamed Nasr
on 17 Apr 2019
thank you the code without any errors now but the result for processing this brain tumor image is a black image![aaa.JPG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/214645/aaa.jpeg)
![aaa.JPG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/214645/aaa.jpeg)
Mohamed Nasr
on 17 Apr 2019
![aaa1.JPG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/214646/aaa1.jpeg)
this is the correct result as it assumed to appear on the right picture
Walter Roberson
on 17 Apr 2019
Please attach the brain image by itself so we can test.
Mohamed Nasr
on 17 Apr 2019
![c.JPG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/214647/c.jpeg)
the original image
More Answers (2)
Mohamed Nasr
on 18 Apr 2019
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 Comments
Walter Roberson
on 18 Apr 2019
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
on 20 Apr 2019
I change label=ligical(bw); To label = bwlabel(logical(bw)); And i have this error message
Mohamed Nasr
on 20 Apr 2019
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
Mohamed Nasr
on 20 Apr 2019
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
on 20 Apr 2019
this link contain all the original photos that was tested by the programer on the video
you should found
Mohamed Nasr
on 20 Apr 2019
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
on 20 Apr 2019
Walter Roberson
on 20 Apr 2019
Is there still and active question here?
Mohamed Nasr
on 21 Apr 2019
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
on 21 Apr 2019
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
Walter Roberson
on 21 Apr 2019
Code attached.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)