embedding image processing codes

2 次查看(过去 30 天)
osman
osman 2012-6-2
Hello, I am trying to get snapshot from webcam and to trace the boundary of the obje. I need to send this boundary coordinates to an other block. Can I reach my target , using trace boundary blockset ? Or should I embed the codes in matlab function blockset. By the way I am using : bwtraceboundary , getsnapshot,rgb2gray,graythresh ect. I tried to embed but it gived some error. " not supported in stand alone codes." Best Regards
  1 个评论
osman
osman 2012-6-3
edgeImage = sobel(originalImage, threshold)
% Sobel edge detection. Given a normalized image (with double values)
% return an image where the edges are detected w.r.t. threshold value.
function edgeImage = sobel(originalImage, threshold) %#codegen
assert(all(size(originalImage) <= [1024 1024]));
assert(isa(originalImage, 'double'));
assert(isa(threshold, 'double'));
k = [1 2 1; 0 0 0; -1 -2 -1];
H = conv2(double(originalImage),k, 'same');
V = conv2(double(originalImage),k','same');
E = sqrt(H.*H + V.*V);
edgeImage = uint8((E > threshold) * 255); this is the demo for edge detection cen be used in matlab function . What I want is to make same thing but need to trace boundary and get an output of row and colm please help me I looked almost everywhere in documantation of matlab.

请先登录,再进行评论。

回答(3 个)

Image Analyst
Image Analyst 2012-6-3
Any reason why you're using bwtraceboundary, where you have to be absolutely sure you give it a starting point on the boundary to start from, rather than bwboundaries, which doesn't require that? Or even find() if all you want are coordinates and don't need connected sets of coordinates.

osman
osman 2012-6-3
Hello , Unfortunately I have to get connected sets of coordinates. I am a user of MatLab for 2 months. I am preparing a final project in my university. As I learnt till today from documentation I can use only bwboundaries command to get boundary coordinates of the object aquired by webcam. I have to getsnapshot with webcam and I have to find set of boundaries of object. I have to embed this functions in matlabfunction blockset . My codes:
clear all; clc;
obj=videoinput('winvideo',2,'RGB24_640x480');
set(obj,'SelectedSourceName','input')
preview(obj);
frame=getsnapshot(obj);
I = rgb2gray(frame); % I can do this with other simulink blocks
threshold = graythresh(I); % I can do this with other simulink blocks
bw = im2bw(I,threshold); % I can do this with other simulink blocks
imshow(bw)
% clear lower than 30 pixels
% fill tiny empties
se = strel('disk',1);
bw = imclose(bw,se);
bw = imfill(bw,'holes');
imshow(bw)
[B,L] = bwboundaries(bw,'noholes'); % the most importent thing in here
% her bir sınırı çiz
imshow(label2rgb(L, @jet, [.6 .0 .3]))
hold on
for k = 1:length(B)
boundary = B{k};
plot(boundary(:,2), boundary(:,1), 'w', 'LineWidth', 2)
end
I have to embed these functions into matlab function or any other simulink blocks. How can I use these function in simulink blocks. It leads me to look at coder documantation but there is no thing in documantations about my problem (bwboundaries) . Please help me I have to solve this problem in 3 days.
  1 个评论
Image Analyst
Image Analyst 2012-6-3
Well I don't use Simulink but I use bwboundaries all the time so I know this is definitely not true: "I can use only bwboundaries command to get boundary coordinates of the object aquired by webcam" You can use it on any binary image no matter how you got it or created it.

请先登录,再进行评论。


osman
osman 2012-6-3
I tried to use trace boundary block set but starting point is problem. I will not trace of a video . I will get snapshot and trace boundaries. so my variables are stationary

类别

Help CenterFile Exchange 中查找有关 Computer Vision with Simulink 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by