Rotate MATLAB Image into Image

I created a graph similar to

figure; hold; axis([0 10 0 10]); fill([ 1 1 5 5], [5 1 1 5],'b') 

and now I want this plot to be a matrix so that I can filter the blog Gaussian. Googleing I found this thread Screen rasterization to image in MATLAB Central. I tried this, but I could only get it to work on line or functional graphs.

Do you have any ideas?

+5
matlab plot filtering rasterizing
source share
2 answers

You can use the getframe function. It returns the frame structure of the frame, which is actually a rasterized figure. The cdata field will contain your matrix.

 F=getframe; figure(2) imagesc(F.cdata); 
+8
source share

What are the desired characteristics of your target matrix? And what images do you want to rasterize?

You see, for the only example you gave us, it’s almost trivial to define a matrix representing your image ...

 1. figmat = ones(10,10,3) % create a 10x10 raster where each entry is a triple for RGB, setting them all to 1 colours the whole raster white 2. figmat(2:5,2:5,1:2) = 0 % sets RG components in the coloured area to 0, leaving only blue 

Your matrix is ​​a raster, for starters. Now you can use the built-in function image to visualize your matrix. See the documentation for this feature. Please note that my suggestion does not meet the specification for use with image () and colormap ().

0
source share

All Articles