Categories
Software

Shapes in deep shadows and high lights in Matlab

Normally I work in different toolboxes of Matlab on purpose. Either it is for my research project purposes  or due to my research project purposes. That is why I came up with an idea to do something in Matlab that would not have any application. I wanted to do something what would look nice and be by itself. Later of course I found some interesting application areas of my work but let us start from the beginning.

Łukasz Kocewiak
Photograph by Magdalena Sozańska

I decided to use Image Processing Toolbox because, in my opinion, no matter of what working on images should always give interesting results. Why not to use some of my pictures from the past taken with my old Minolta Dynax 700si. I still should have it somewhere in the basement.

%% Gausian convolution matrix
G= [1  4  7  4 1;
    4 16 26 16 4;
    7 26 41 26 7;
    4 16 26 16 4;
    1  4  7  4 1];
G= G/sum(sum(G));

%% Picture analysis
ExampleUint= imread('Example.jpg');
ExampleDouble= double(ExampleUint);
[m n]= size(ExampleDouble(:,:,1));

%%  Linear Gaussian filter
ExampleFilterUint= imfilter(ExampleUint,G,'conv');
for k=1:10,
    ExampleFilterUint= imfilter(ExampleFilterUint,G,'conv');
    k= k+1; %#ok<FXSET>
end
ExampleFilterDouble= double(ExampleFilterUint);

Due to the fact that the picture was taken still in analog technology and scanned in any photo lat the quality is not so good. Even in the small picture (a) noise can be clearly seen. I decided to get rig of it by application of a digital filter. A lot of noise and sharp edges that can affect the final result. In order to make the picture more smooth we will use a low-pass filter (b). I decided to use Gaussian filter with the convolution matrix as presented above.

Łukasz Kocewiak 3DThis apprioach can be succesfully used if we would like to evaluate how objects are shaped by light. A good example is in case of body shaping by either attending gym or fitness. If we simply cannot assess if our muscles are sufficiently shaped, just take a picture and do some processing in Matlab. Probably other applications can be found. Please let me know if you have any suggestions by posting a comment.

And an exemplary code from Matlab showing how to display two-dimensional matrix of double precision numbers.

scrsz= get(0,'ScreenSize');
%% Show results
fi1= figure('Name','3D Plot',...
     'Position',[0.1*scrsz(3) 0.1*scrsz(4) 0.35*scrsz(3) 0.5*scrsz(4)]);
ax1= axes('Parent',fi1,'FontName','Verdana','FontSize',10);
grid(ax1,'on'),hold(ax1,'all'),
mesh(ExampleFilterDouble(:,:,1)),colormap('hot'),
view(ax1,[-150 70]),xlim([0 n]),ylim([0 m]),

Leave a Reply

Your email address will not be published. Required fields are marked *