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]),
Categories
Software

How to open SVG 1.1 in Visio 2007

A while ago I had a horrible problem with MS Visio 2007. I was really happy that I did manage to prepare nice vector graphics in Adobe Illustrator CS4. Among others it was a map indicating one of onshore wind farms that I analyze within the confines of my research project. Normally at work I do not have such fancy tools as Adobe software, so I had to save results in something that MS Visio would be able to open.

Clipping Path 1
Vector graphics created in Adobe Illustrator CS4.


I decided to use an open standard vector format such as SVG is. Since it is an open standard it should be possible to easily save it in Illustrator and hypothetically without any problems open in Visio. I would like to emphasize that this version (i.e. SVG 1.1)  was developed in 2003 as it is stated on the W3C website. Actually Visio can deal with SVG 1.1 but in a selective manner. How big was my disappointment when I realized that actually well described in the standard clipping path is not supported.

The same drawing with visible clipping path.

The description of the clipping path (commonly known in popular vector graphics applications) can be found on the W3C (Clipping Path) website. An exemplary code showing an application of the clipping path from an SVG file generated by Adobe Illustrator looks in the following way

<defs>
     <path id="SVGID_1_" d="M111.478,271.964c0,0-5.669,0-5.669,5.478z"/>
</defs>
<clipPath id="SVGID_2_">
     <use xlink:href="#SVGID_1_"  overflow="visible"/>
</clipPath>

If one would like to open such kind of SVG file with clipping path in Visio the error dialog box appears which is presented below. MS Visio 2007 is simply not capable to open files  including clipping path definitions. I tried to find any solution how to deal with this problem via Internet but unsuccessfully.

In the error log file generated by the software it is clearly stated which elements from SVG structure are incompatible. One of possibilities to work around this problem is to delete unsupported fragments of the code. Of course this would affect that elements of our vector graphics which should be hidden by the clipping path will be visible.

[Warning] DataType: Element <clipPath>
Context: Line 13 ID SVGID_2_
Description: Invalid children of clip-path element. Children removed

Please remember also to remove information about the clipping path from each of elements included in the vector graphics. Later in MS Visio 2007 it is possible to use other methods of masking unwanted elements or parts of them.

I hope this help and please shear your experience with me regarding this problem by adding a comment. Cheers!