reference to non-existent field solidity

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

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

13 Comments

you mean I will edit
stats.solidity
to
stats.Solidity with Capital S Letter on all my code ?!
Mohamed Nasr
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' );
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}
Solidity error was solved thanks alot but there still another error I copied all my code to see it This is the last error
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];
thank you the code without any errors now but the result for processing this brain tumor image is a black imageaaa.JPG
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.
c.JPG
the original image

Sign in to comment.

More Answers (2)

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

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));
I change label=ligical(bw); To label = bwlabel(logical(bw)); And i have this error message
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
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
Is there still and active question here?
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
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

Sign in to comment.

Thanks alot really for your patient and your support

Categories

Products

Community Treasure Hunt

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

Start Hunting!