How do i output character string on my code?
Show older comments
So i'm working on project that outputs chess moves by using image processing to detect differences in the picture then my program out put chess move. Thanks to help Jan Simon one of the guys on MATLab central i sucessfully am able to ouput the correct chess moves. But i have one problem that might be easy to answer. When i run the program i am given two chess cell A=C6 A=E4. Which is correct but i want I want MATLab to output A = C6E4, instead of two different equations. I guess that is a string, please help.
My code
q3=imread('image3.jpg');
q4=imread('image4.jpg');
gray3 = imabsdiff(q3,q4);
RowName = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'};
ColName = {'1', '2', '3', '4', '5', '6', '7', '8'};
RowPos = 5:120:955;
ColPos = 160:120:1114;
A = [];
for row = 1:8
start_row = RowPos(row);
for col = 1:8
start_col = ColPos(col);
crop = gray3(start_row+33:start_row+98, ...
start_col+33:start_col+98, :);
b = find(crop >180); % *Not* the whole gray5 array!
% figure,imshow(crop)
% if ~isempty(b) % Better:
if any(crop(:) > 180)
A = [RowName{row}, ColName{col}]
end
end
end
Output--------------------------------------------
A =
C6
A =
E4
I want A= C6E4
thank you
Answers (1)
Walter Roberson
on 11 Mar 2011
In your loop,
A = [A RowName{row} ColName{col}];
Categories
Find more on Graph and Network Algorithms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!