Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 0bf0bd61 authored by hhakim's avatar hhakim
Browse files

Add matfaust.Faust.imagesc() and pyfaust.Faust.imshow().

parent 01ee148e
No related branches found
No related tags found
No related merge requests found
......@@ -1502,6 +1502,8 @@ classdef Faust
%===
%> It's equivalent to cat(2, F, A, B, …).
%>
%> This function overloads a Matlab built-in function.
%>
%> @b Usage
%>
%> &nbsp;&nbsp;&nbsp; @b C=HORZCAT(F,A) concatenates the Faust F and A horizontally. A is a Faust or a sparse/full matrix. The result is the Faust C. @b HORZCAT(F,A) is the same as [F,G].<br/>
......@@ -1516,8 +1518,11 @@ classdef Faust
%======================================================================
%> Vertical concatenation [F;A;B;…] where F is a Faust and A, B, … are Faust objects or sparse/full matrices.
%===
%>
%> It's equivalent to cat(1, F, A, B, …).
%>
%> This function overloads a Matlab built-in function.
%>
%> @b Usage
%>
%> &nbsp;&nbsp;&nbsp; @b C=VERTCAT(F,A) concatenates the Faust F and A vertically. A is a Faust or a sparse/full matrix. The result is the Faust C. @b VERTCAT(F,A) is the same as [F;G].<br/>
......@@ -1537,6 +1542,39 @@ classdef Faust
error('Function not implemented in the Faust class.');
end
%=====================================================================
%> Displays image of F's full matrix and its factors.
%===
%> This function overloads a Matlab built-in function.
%>
%> @b Usage
%>
%> &nbsp;&nbsp;&nbsp; @b imagesc(F)
%>
%> Data is scaled to use the full colormap.
%>
%> @b Example
%> @code
%> import matfaust.FaustFactory
%> F = FaustFactory.rand(5, [50, 100], .5, 'mixed', 'complex')
%> imagesc(F)
%> print('test_imsc', '-dpng')
%> @endcode
%>
%> <p>@b See @b also Faust.disp.
%======================================================================
function imagesc(F)
numfacts = get_num_factors(F);
subplot(1,numfacts+1,1); imagesc(abs(real(full(F))));
set(gca,'XTick',[], 'YTick', []);
for i=1:numfacts
subplot(1,numfacts+1,1+i);
fac = get_factor(F,i);
imagesc(abs(real(fac)));
set(gca,'XTick',[], 'YTick', []);
end
end
end
methods(Static)
end
......
......@@ -1086,6 +1086,34 @@ class Faust:
else:
return np.dtype(np.complex)
def imshow(F):
"""
Displays image of F's full matrix and its factors.
<b> See also Faust.display. </b>
Examples:
>>> from pyfaust import FaustFactory
>>> import matplotlib.pyplot as plt
>>> F = FaustFactory.rand([2, 3], [10, 20],.5, field='complex')
>>> F.imshow()
>>> plt.show()
"""
import matplotlib.pyplot as plt
nf = F.get_num_factors()
plt.subplot(1,nf+1,1)
plt.imshow(abs(F.toarray()),extent=[0,100,0,1], aspect='auto')
plt.xticks([]); plt.yticks([])
for i in range(0,nf):
plt.subplot(1,F.get_num_factors()+1,i+2)
fac = F.get_factor(i)
if(not isinstance(fac, np.ndarray)):
fac = fac.toarray()
plt.xticks([]); plt.yticks([])
plt.imshow(abs(fac),extent=[0,100,0,1], aspect='auto')
class FaustFactory:
"""
This factory class provides methods for generating a Faust especially by factorization of a dense matrix.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment