I was wrong, de disp in the previous post had to be in this way:
disp(['the area is:' num2str(white_pixel_count) 'pixels']);
Then, you have to add the code for the conversion, combining the two codes I gave you:
referenceObjectLengthInCentemeters=100;
referenceObjectLengthInPixels=1000;
Image=zeros(30); Image(4:6,4:6)=1;
figure();imshow(Image);
objectAreaInPixels=length(find(Image==1));
centemetersInOnePixel=referenceObjectLengthInCentemeters/referenceObjectLengthInPixels;
centemetersInOnePixelSquare=centemetersInOnePixel^2;
objectAreaInCentemeters=objectAreaInPixels*centemetersInOnePixel;
disp(['the area is:' num2str(objectAreaInCentemeters) 'cm2']);
Let's try this code with the phantom image so that you can check the steps of the code by hand, and understand what you are doing.