{"id":44,"date":"2011-09-27T20:49:45","date_gmt":"2011-09-27T19:49:45","guid":{"rendered":"http:\/\/lukasz.kocewiak.eu\/blog\/?p=44"},"modified":"2012-10-05T16:09:29","modified_gmt":"2012-10-05T15:09:29","slug":"shapes-in-deep-shadows-and-high-lights-in-matlab","status":"publish","type":"post","link":"https:\/\/lukasz.kocewiak.eu\/blog\/2011\/09\/27\/shapes-in-deep-shadows-and-high-lights-in-matlab\/","title":{"rendered":"Shapes in deep shadows and high lights in Matlab"},"content":{"rendered":"<p>Normally I work in different toolboxes of Matlab on purpose. Either it is for my research project purposes\u00a0 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.<\/p>\n<figure id=\"attachment_49\" aria-describedby=\"caption-attachment-49\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/uploads\/2011\/09\/ExampleFiltered.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-49\" title=\"ExampleFiltered\" src=\"http:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/uploads\/2011\/09\/ExampleFiltered-300x165.png\" alt=\"\u0141ukasz Kocewiak\" width=\"300\" height=\"165\" srcset=\"https:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/uploads\/2011\/09\/ExampleFiltered-300x165.png 300w, https:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/uploads\/2011\/09\/ExampleFiltered.png 559w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-49\" class=\"wp-caption-text\">Photograph by Magdalena Soza\u0144ska<\/figcaption><\/figure>\n<p>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.<\/p>\n<pre>%% Gausian convolution matrix\r\nG= [1  4  7  4 1;\r\n    4 16 26 16 4;\r\n    7 26 41 26 7;\r\n    4 16 26 16 4;\r\n    1  4  7  4 1];\r\nG= G\/sum(sum(G));\r\n\r\n%% Picture analysis\r\nExampleUint= imread('Example.jpg');\r\nExampleDouble= double(ExampleUint);\r\n[m n]= size(ExampleDouble(:,:,1));\r\n\r\n%%  Linear Gaussian filter\r\nExampleFilterUint= imfilter(ExampleUint,G,'conv');\r\nfor k=1:10,\r\n    ExampleFilterUint= imfilter(ExampleFilterUint,G,'conv');\r\n    k= k+1; %#ok&lt;FXSET&gt;\r\nend\r\nExampleFilterDouble= double(ExampleFilterUint);<\/pre>\n<p>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.<\/p>\n<p><a href=\"http:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/uploads\/2011\/09\/ExampleMesh.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-59\" title=\"ExampleMesh\" src=\"http:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/uploads\/2011\/09\/ExampleMesh-300x267.png\" alt=\"\u0141ukasz Kocewiak 3D\" width=\"300\" height=\"267\" srcset=\"https:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/uploads\/2011\/09\/ExampleMesh-300x267.png 300w, https:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/uploads\/2011\/09\/ExampleMesh.png 504w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a>This 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.<\/p>\n<p>And an exemplary code from Matlab showing how to display two-dimensional matrix of double precision numbers.<\/p>\n<pre>scrsz= get(0,'ScreenSize');\r\n%% Show results\r\nfi1= figure('Name','3D Plot',...\r\n     'Position',[0.1*scrsz(3) 0.1*scrsz(4) 0.35*scrsz(3) 0.5*scrsz(4)]);\r\nax1= axes('Parent',fi1,'FontName','Verdana','FontSize',10);\r\ngrid(ax1,'on'),hold(ax1,'all'),\r\nmesh(ExampleFilterDouble(:,:,1)),colormap('hot'),\r\nview(ax1,[-150 70]),xlim([0 n]),ylim([0 m]),<\/pre>\n<div class='shareinpost'><ul class=\"socialwrap row\"><li class=\"iconOnly\"><a rel=\"nofollow\" target=\"_blank\" href=\"http:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Flukasz.kocewiak.eu%2Fblog%2F2011%2F09%2F27%2Fshapes-in-deep-shadows-and-high-lights-in-matlab%2F&amp;t=Shapes+in+deep+shadows+and+high+lights+in+Matlab\" title=\"Recommend this post : Shapes in deep shadows and high lights in Matlab on Facebook\" ><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/plugins\/share-and-follow\/images\/blank.gif\" height=\"24\" style=\"background: transparent url(http:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/plugins\/share-and-follow\/default\/24\/sprite-24.png) no-repeat;padding:0;margin:0;height:24px;width:24px;background-position:-275px 0px\" class=\"image-24\" width=\"24\" alt=\"facebook\"\/> <span class=\"head\">Recommend on Facebook<\/span><\/a><\/li><li class=\"iconOnly\"><a rel=\"nofollow\" target=\"_blank\" href=\"http:\/\/www.linkedin.com\/shareArticle?mini=true&amp;url=https%3A%2F%2Flukasz.kocewiak.eu%2Fblog%2F2011%2F09%2F27%2Fshapes-in-deep-shadows-and-high-lights-in-matlab%2F&amp;title=Shapes+in+deep+shadows+and+high+lights+in+Matlab&amp;&amp;summary=Normally+I+work+in+different+toolboxes+of+Matlab+on+purpose.+Either+it+is+for+my+research+project+purposes%C2%A0+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+\" title=\"Share this post : Shapes in deep shadows and high lights in Matlab on Linkedin\" ><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/plugins\/share-and-follow\/images\/blank.gif\" height=\"24\" style=\"background: transparent url(http:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/plugins\/share-and-follow\/default\/24\/sprite-24.png) no-repeat;padding:0;margin:0;height:24px;width:24px;background-position:-675px 0px\" class=\"image-24\" width=\"24\" alt=\"linkedin\"\/> <span class=\"head\">Share on Linkedin<\/span><\/a><\/li><li class=\"iconOnly\"><a rel=\"nofollow\" target=\"_blank\" href=\"http:\/\/twitter.com\/home\/?status=https%3A%2F%2Flukasz.kocewiak.eu%2Fblog%2F2011%2F09%2F27%2Fshapes-in-deep-shadows-and-high-lights-in-matlab%2F\" title=\"Tweet this post : Shapes in deep shadows and high lights in Matlab on Twitter\" ><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/plugins\/share-and-follow\/images\/blank.gif\" height=\"24\" style=\"background: transparent url(http:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/plugins\/share-and-follow\/default\/24\/sprite-24.png) no-repeat;padding:0;margin:0;height:24px;width:24px;background-position:-1325px 0px\" class=\"image-24\"  width=\"24\"  alt=\"twitter\"\/> <span class=\"head\">Tweet about it<\/span><\/a><\/li><li class=\"iconOnly\"><a rel=\"_self\" href=\"https:\/\/lukasz.kocewiak.eu\/blog\/2011\/09\/27\/shapes-in-deep-shadows-and-high-lights-in-matlab\/feed\" title=\"Follow this post : Shapes in deep shadows and high lights in Matlab comments\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/plugins\/share-and-follow\/images\/blank.gif\" height=\"24\"  width=\"24\" style=\"background: transparent url(http:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/plugins\/share-and-follow\/default\/24\/sprite-24.png) no-repeat;padding:0;margin:0;height:24px;width:24px;background-position:-1100px 0px\" class=\"image-24\"  alt=\"rss\" \/> <span class=\"head\">Subscribe to the comments on this post<\/span><\/a><\/li><li class=\"iconOnly\"><a rel=\"_self\" href=\"mailto:?subject=\u0141ukasz%20Kocewiak%20:%20Shapes%20in%20deep%20shadows%20and%20high%20lights%20in%20Matlab&amp;body=here%20is%20a%20link%20to%20a%20site%20I%20really%20like.%20%20%20https:\/\/lukasz.kocewiak.eu\/blog\/2011\/09\/27\/shapes-in-deep-shadows-and-high-lights-in-matlab\/\" title=\"Tell a friend about this post : Shapes in deep shadows and high lights in Matlab \"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/plugins\/share-and-follow\/images\/blank.gif\" height=\"24\"  width=\"24\" style=\"background: transparent url(http:\/\/lukasz.kocewiak.eu\/blog\/wp-content\/plugins\/share-and-follow\/default\/24\/sprite-24.png) no-repeat;padding:0;margin:0;height:24px;width:24px;background-position:-250px 0px\" class=\"image-24\"  alt=\"email\" \/> <span class=\"head\">Tell a friend<\/span><\/a><\/li><\/ul><div class=\"clean\"><\/div> <\/div>","protected":false},"excerpt":{"rendered":"<p>Normally I work in different toolboxes of Matlab on purpose. Either it is for my research project purposes\u00a0 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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[15,7],"class_list":["post-44","post","type-post","status-publish","format-standard","hentry","category-software","tag-data-processing","tag-matlab"],"_links":{"self":[{"href":"https:\/\/lukasz.kocewiak.eu\/blog\/wp-json\/wp\/v2\/posts\/44","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lukasz.kocewiak.eu\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lukasz.kocewiak.eu\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lukasz.kocewiak.eu\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lukasz.kocewiak.eu\/blog\/wp-json\/wp\/v2\/comments?post=44"}],"version-history":[{"count":20,"href":"https:\/\/lukasz.kocewiak.eu\/blog\/wp-json\/wp\/v2\/posts\/44\/revisions"}],"predecessor-version":[{"id":270,"href":"https:\/\/lukasz.kocewiak.eu\/blog\/wp-json\/wp\/v2\/posts\/44\/revisions\/270"}],"wp:attachment":[{"href":"https:\/\/lukasz.kocewiak.eu\/blog\/wp-json\/wp\/v2\/media?parent=44"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lukasz.kocewiak.eu\/blog\/wp-json\/wp\/v2\/categories?post=44"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lukasz.kocewiak.eu\/blog\/wp-json\/wp\/v2\/tags?post=44"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}