Code covered by the BSD License  

Highlights from
ImProc application created with MATLAB(R) Compiler(TM) and Visual Studio(R)

image thumbnail

ImProc application created with MATLAB(R) Compiler(TM) and Visual Studio(R)

by

 

21 Apr 2009 (Updated )

How to integrate a MATLAB(R) generated C++ DLL with a Visual Studio(R) MFC application

myhistimage(in)
function [out] = myhistimage(in)
% Copyright 2009 The MathWorks, Inc.

persistent bitmapHandle;

if ishandle(bitmapHandle)
    figure(bitmapHandle);
    set(bitmapHandle, 'Visible', 'off');
    cla;
else
    bitmapHandle = figure('Visible', 'off');
    set(bitmapHandle, 'Color', [1 1 1]);
    set(bitmapHandle, 'PaperPositionMode', 'auto');
end;

a = get(bitmapHandle, 'Position');
s = size(in);
a(3) = s(1);
a(4) = s(2);

[X, count] = imhist(in);
stem(count, X, '-', '.');

axis tight;
set(bitmapHandle, 'Position', a);
pixels = hardcopy(bitmapHandle,'-dOpenGL','-r0');

% Size of the bitmap produced by hardcopy may be larger than that 
% specified by the figure width & height.
% Also transpose to get the correct bitmap orientation for .ToVector
for i = 3:-1:1, 
    pixs(:,:,i) = pixels(1:s(2),1:s(1),i)'; %#ok
end;
out = rgb2gray(pixs);

Contact us