Converting my .m file to .c code

1 view (last 30 days)
Vamsi Yuvaraj Suggula
Vamsi Yuvaraj Suggula on 29 Apr 2014
Commented: Ryan Livingston on 29 Apr 2014
Hi every one, I am trying to convert a .m file to .c for my final year project for hardware implementation. The code I'm trying to work on is:
clc;
clear all;
close all;
a(:,:,:,1)=imread('C:\Users\shamiliraj\Contacts\Desktop\traffic.jpg');
a(:,:,:,2)=imread('C:\Users\shamiliraj\Contacts\Desktop\traffic.jpg');
a(:,:,:,3)=imread('C:\Users\shamiliraj\Contacts\Desktop\traffic.jpg');
a(:,:,:,4)=imread('C:\Users\shamiliraj\Contacts\Desktop\traffic.jpg');
red1=a(:,:,1,1);
green1=a(:,:,2,1);
blue1=a(:,:,3,1);
objects1=red1-green1-blue1;
bwobjects11=objects1>(40);
rect11=[0 0 2000 1319];
cr11=imcrop(bwobjects11,rect11);
figure,imshow(cr11);
[bw11,n1]=bwlabel(cr11);%the no. of objects in the region are assigned to n1
disp(n1);
%second image
red2=a(:,:,1,2);
green2=a(:,:,2,2);
blue2=a(:,:,3,2);
objects2=red2-green2-blue2;
bwobjects22=objects2>(40);
rect21=[0 0 2000 1319];
cr21=imcrop(bwobjects22,rect21);
figure,imshow(cr21);
[bw21,n2]=bwlabel(cr21);
disp(n2);
%third image
red3=a(:,:,1,3);
green3=a(:,:,2,3);
blue3=a(:,:,3,3);
objects3=red3-green3-blue3;
bwobjects33=objects3>(40);
rect31=[0 0 2000 1319];
cr31=imcrop(bwobjects33,rect31);
figure,imshow(cr31);
[bw31,n3]=bwlabel(cr31);
disp(n3);
%fourth image
red4=a(:,:,1,4);
green4=a(:,:,2,4);
blue4=a(:,:,3,4);
objects4=red4-green4-blue4;
bwobjects44=objects4>(40);
rect41=[0 0 2000 1319];
cr41=imcrop(bwobjects44,rect41);
figure,imshow(cr41);
[bw41,n4]=bwlabel(cr41);
disp(n4);
t1=5;
t2=5;
t3=5;
t4=5;
t1=t1+(n1/2);
t2=t2+(n2/2);
t3=t3+(n3/2);
t4=t4+(n4/2);
if(t1>90)
t1=90;
end
if(t2>90)
t2=90;
end
if(t3>90)
t3=90;
end
if(t4>90)
t4=90;
end
disp(t1);
disp(t2);
disp(t3);
disp(t4);
I already installed matlab coder but unable to use it in the right way. Please guide me. Any help is greatly appreciated.
Thanks Vamsi Yuvaraj

Answers (1)

Walter Roberson
Walter Roberson on 29 Apr 2014
The difference is that in converting to C you can supply your own routines by those names, routines you write to interact with the hardware directly or with vendor-supplied libraries that interact with the hardware.
  1 Comment
Ryan Livingston
Ryan Livingston on 29 Apr 2014
Also, for converting to C code, the documentation describing requirements and/or limitations regarding your MATLAB code is available at:

Sign in to comment.

Categories

Find more on Graphics Object Programming in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!