Q:

binary or contiuous image?

I have an image which I want to use it in MATLAB. But, I am looking for a method by which I be able to automatically find that my image is binary (0 and 1) or continuous. Is there any solution of piece of code?

A:

For starters you cannot formally talk about binary or continuous images. Digital images have a discrete set of values, taken from a finite value set depending on their format and pixel bit-wise representation. 
For example a "binary" image would have 2 levels of gray (white and black), represented by 0 or 1 or any other combination of values, e.g. an image of levels 0, 255 is still "binary". A  grayscale image for an 8-bit representation (i.e. 8 bits per pixel) will have 2^8 discrete levels of intensity from min 0 (black) to max 255 (white). 
Thus you can test for the number of unique levels of gray, i.e. unique values in your input image: 
I = imread(image_filename); 
if length(unique(I))==2, 
    flag_binary = true 
end 

Examples:
I = imread('cameraman.tif');
>> disp(flag_binary)
     0
I = imread('circles.png');
>> disp(flag_binary)
     1

A:

From your question I'm guessing you are dealing only with images of the logical or double class. The first should be used for real binary images but unfortunately, that's not always the case when using code out in the wild.
It seems to me your problem is to distinguish between a real image of double class (all values between 0 and 1) or a binary image as class double (all values are 0 or 1). The best way to do it is the following which returns true if the image only has the values 1 and 0:
bool = all ((image(:) == 1) + (image(:) == 0));

This is a line from isbw() in Octave image package where you can use isbw (img, "non-logical")

