MATLAB: Image load problem (HELP)

bitdepthimage

Hi , my question is How to load different type of image into program.
I have two type of image which are 8bit depth (grayscale) and 24bit depth (RGB).
However, the wiener2 noise filter function only can read image with 8 bit depth .
The following code is my idea ,but I don't know how to define the bit depth of a /chosenfile .It is possible to work ? or any idea?
[file path] = uigetfile('*.jpg','Select any image');
chosenfile = [path file];
a = imread(chosenfile);
if BitDepth(a) == 24 ;
b=rgb2gray(a);
c=wiener2(b,[2,2]);
axes(handles.axes1)
imshow(c)
handles.c=c;
guidata(hObject, handles)
else
b=wiener2(a,[2,2]);
axes(handles.axes1)
imshow(b)
handles.b=b;
guidata(hObject, handles)
end

Best Answer

if ndims(a) > 2 then a is not grayscale.