i get the error when i m trying to generate the hdl code for a matlab program by hdl coder... the error is 'In emlhdlcode​r.WorkFlow​.Manager/w​fa_generat​eCode (line 627)'... help me to solve this error.. thanks in advance..

2 次查看(过去 30 天)
clc;
clear all;
close all;
image1=imread('C:\Users\dell pc\Pictures\barbaraa.tif');
imag1=rgb2gray(image1);
im1=imresize(imag1,[256 256]);
im2=im2uint8(im1);
subplot(2,2,1);
figure(1);
imshow(im2);title('original image');
image2=stdfilt(im2);
subplot(2,2,2);
imshow(image2,[]);
title('standard deviation map');
t2=0.1*max(max(image2));
for i=1:256
for j=1:256
if image2(i,j) < t2
s(i,j)=0;
else
s(i,j)=1;
end
end
end
subplot(2,2,3);
imshow(s);
title('binarized standard deviation map');
%# desired number of horizontal/vertical tiles to divide the image into
numBlkH = 4;
numBlkW = 4;
%# compute size of each tile in pixels
[imgH,imgW,~] = size(s);
szBlkH = [repmat(fix(imgH/numBlkH),1,numBlkH-1) imgH-fix(imgH/numBlkH)*(numBlkH-1)];
szBlkW = [repmat(fix(imgW/numBlkW),1,numBlkW-1) imgW-fix(imgW/numBlkW)*(numBlkW-1)];
%# divide into tiles, and linearize using a row-major order
C = mat2cell(s, szBlkH, szBlkW)';
C = C(:);
image1=imread('C:\Users\dell pc\Pictures\barbaraa.tif');
imag1=imresize(image1,[256 256]);
numBlkH = 4;
numBlkW = 4;
%# compute size of each tile in pixels
[imgH,imgW,~] = size(im2);
szBlkH = [repmat(fix(imgH/numBlkH),1,numBlkH-1) imgH-fix(imgH/numBlkH)*(numBlkH-1)];
szBlkW = [repmat(fix(imgW/numBlkW),1,numBlkW-1) imgW-fix(imgW/numBlkW)*(numBlkW-1)];
%# divide into tiles, and linearize using a row-major order
P = mat2cell(im2, szBlkH, szBlkW)';
P = P(:);
%# display tiles i subplots
for i=1:numBlkH*numBlkW
subplot(numBlkH,numBlkW,i), imshow( P{i} )
end
figure
a=1;b=1;
for i=1:16
c1(:,:,i)=cell2mat(C(i));
p1(:,:,i)=cell2mat(P(i));
sum1=sum(sum(c1(:,:,i)));
t(:,:,i)=sum1/(64*64);
if t(:,:,i) < 0.85
poortext(:,:,a)=c1(:,:,i);
poortext1(:,:,a)=im2double(p1(:,:,i));
a=a+1;
else
text(:,:,b)=c1(:,:,i);
text1(:,:,b)=p1(:,:,i);
b=b+1;
end
end
for i=1:a-1
d=(poortext1(:,:,i));
subplot(4,4,i)
imshow(d);
title('poor-texture');
end
figure
for i=1:b-1
d1(:,:,i)=(text1(:,:,i));
d2=d1(:,:,i);
subplot(4,4,i)
imshow(d2);
title('texture');
end
% figure
k2=1;
for i=1:b-1
[ll,lh,hl,hh]=dwt2(d1(:,:,i), 'haar');
llc(:,:,k2)=(ll);
% subplot(2,2,1);
% imshow(llc);
lhc(:,:,k2)=(lh);
% subplot(2,2,2);
% imshow(lhc);
hlc(:,:,k2)=(hl);
% subplot(2,2,3);
% imshow(hlc);
hhc(:,:,k2)=(hh);
% subplot(2,2,4);
% imshow(hhc);
k2=k2+1;
end
figure
imag1 = imread('peppers.png');imag2=rgb2gray(imag1);
im3= imresize(imag2, [64, 64]);
imshow(im3);
figure
imag3=im2double(im3);
ima=arnold(imag3,24);
imshow(mat2gray(ima));
[lllo,lhlo,hllo,hhlo]=dwt2(double(ima),'haar');
ll1=mat2gray(lllo);
subplot(2,2,1);
imshow(ll1);
title('LL');
ll1=mat2gray(lllo);
subplot(2,2,2);
imshow(ll1);
title('LH');
lh1=mat2gray(lhlo);
subplot(2,2,3);
imshow(lh1);
title('HL');
hl1=mat2gray(hllo);
subplot(2,2,4);
imshow(hl1);
title('HH');
for i=1:2
llf(:,:,i)=llc(:,:,i)+0.001*lllo;
lhf(:,:,i)=lhc(:,:,i)+0.01*lhlo;
hlf(:,:,i)=hlc(:,:,i)+0.01*hllo;
hhf(:,:,i)=hhc(:,:,i)+0.01*hhlo;
end
figure
for i=1:2
y(:,:,i)=idwt2(llf(:,:,i),lhf(:,:,i),hlf(:,:,i),hhf(:,:,i),'haar');
s1(:,:,i)=mat2gray(y(:,:,i));
a2=s1(:,:,i);
subplot(4,4,i)
imshow(a2);
end
figure
i1=1;
j1=1;
a1(i1:i1+63, j1:j1+63)=poortext1(:,:,1);
a1(i1:i1+63, 65:65+63)=poortext1(:,:,2);
a1(i1:i1+63, 129:129+63)=poortext1(:,:,3);
a1(i1:i1+63, 193:193+63)=mat2gray(s1(:,:,1));
a1(65:65+63, j1:j1+63)=poortext1(:,:,4);
a1(65:65+63, 65:65+63)=poortext1(:,:,5);
a1(65:65+63, 129:129+63)=poortext1(:,:,6);
a1(65:65+63, 193:193+63)=poortext1(:,:,7);
a1(129:129+63, j1:j1+63)=poortext1(:,:,8);
a1(129:129+63, 65:65+63)=poortext1(:,:,9);
a1(129:129+63, 129:129+63)=poortext1(:,:,10);
a1(129:129+63, 193:193+63)=poortext1(:,:,11);
a1(193:193+63, j1:j1+63)=poortext1(:,:,12);
a1(193:193+63, 65:65+63)=mat2gray(s1(:,:,2));
a1(193:193+63, 129:129+63)=poortext1(:,:,13);
a1(193:193+63, 193:193+63)=poortext1(:,:,14);
imshow(a1);
for i=1:2
lle(:,:,i)=(llc(:,:,i)-llf(:,:,i))/0.001;
lhe(:,:,i)=(lhc(:,:,i)-lhf(:,:,i))/0.01;
hle(:,:,i)=(hlc(:,:,i)-hlf(:,:,i))/0.01;
hhe(:,:,i)=(hhc(:,:,i)-hhf(:,:,i))/0.01;
end
figure
for i=1:2
f(:,:,i)=idwt2(lle(:,:,i),lhe(:,:,i),hle(:,:,i),hhe(:,:,i),'haar');
s2=mat2gray(f(:,:,i));
subplot(4,4,i)
imshow(s2);
figure
ima2=iarnold(s2,24);
ima1=imcomplement(ima2);
% subplot(7,7,inc)
imshow(ima1)
figure
iminverse1=im2double(ima1);
cc1=corr2(imag3,ima1)
end
% % PSNR
image3=im2double(im1);
peaksnr = psnr(image3,a1);
cc=corr2(image3,a1);
% % NCC
this is my test script..

采纳的回答

Tim McBrayer
Tim McBrayer 2017-1-6
编辑:Tim McBrayer 2017-1-6
It's hard to say what your immediate problem is with no error message listed, but I strongly suspect that you are using functions that are not supported for HDL code generation. The first several commands in your code are all not supported by HDL Coder. I expect that they all belong in the testbench and not the code you want to generate HDL from. Your code starts with:
clc;
clear all;
close all;
image1=imread('C:\Users\dell pc\Pictures\barbaraa.tif');
imag1=rgb2gray(image1);
im1=imresize(imag1,[256 256]);
im2=im2uint8(im1);
subplot(2,2,1);
figure(1);
imshow(im2);
title('original image');
image2=stdfilt(im2);
subplot(2,2,2);
imshow(image2,[]);
title('standard deviation map');
There's literally nothing in this code fragment that you can generate hardware out of.
  1 个评论
Walter Roberson
Walter Roberson 2017-1-6
You should be able to generate hardware out of the rgb2gray and the im2uint8, perhaps the stdfilt() as well. But you would not want to do the im2uint8 in hardware: it would be a waste of hardware resources (because if the data is floating point in the file then you would need full floating point cores, and if the data is not floating point in the file then the im2uint8 is mostly pointless.) I guess there is a possibility that you might have a use for rgb2gray in hardware, but if so then I would expect that it would be in the context of using the Vision HDL toolbox.

请先登录,再进行评论。

更多回答(0 个)

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by