Hello everyone,
I'm trying to determine the average RGB colour of lines detected in an image through a Hough transform. I have calcuated the mean of each individual line successful, but I want the mean of all of the lines that are found. The amount of lines could change each time.
for k = 1:length(lines) xy = [lines(k).point1; lines(k).point2]; plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green'); % Plot beginnings and ends of lines
plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow'); plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red'); % find average road colour - get all co-ords between endpoints
[x, y]=bresenham(xy(1,1),xy(1,2),xy(2,1),xy(2,2)); LineCoOrds{k}=[x, y]; % Get RGB values for these points & their mean
P{k} = impixel(I,x,y); Meanpix{k}=mean(P{k});end
I have tried methods such as below, but havent got it quite right.
TotalMeanPixel=cellfun(@mean, Meanpix);
I'm fairly new to Matlab so any help is appreciated a lot.
EDIT – Just to clarify, I want the mean of each individual column, e.g. first column, for all the cells in Meanpix, so I ended up with one value for RGB. I need the average colour of all the lines detected.
Many thanks!
Liz
Best Answer