how to convert matrix to image???

3 views (last 30 days)
how do i convert matrix containing 1st column-x position 2nd column-y position 3rd column-height 4th column-width into output image it should compare with the original image and extract the components from it.
Please do help me
  4 Comments
Stephen23
Stephen23 on 26 Jul 2017
@stark iron: how to do this? Just like solving any other task: the first thing is to understand the task itself: you do not need a computer and certainly MATLAB is not needed for this. Think about what you have, what you need, and what possible steps will be required. Plan it on a large piece of paper. Once you understand how this can be done, then start to think about what code could be used to do this. Come and ask us about specific commands or steps.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 26 Jul 2017
Guessing at what you mean about "compare with the original image and extract the components from it":
Assuming the control information is in YourMatrix and that the original image is YourImage:
ncol = size(YourMatrix, 1);
outputs = cell(ncol,1);
for K = 1 : ncol
x = YourMatrix(K,1);
y = YourMatrix(K,2);
high = YourMatrix(K,3);
wide = YourMatrix(K,4);
this_extract = YourImage(y:y+high-1, x:x+wide-1, :);
outputs{K} = this_extract;
end
Now outputs is a cell array containing the sub-sections of the image.
Somehow, I suspect that what you want to do is feature extraction based on the extracted portions and compare the results against a database of features of OCR'd characters to figure out which character you are probably looking at. Not that you said anything like that, but...
By the way, please re-check that the height is in the third position and the width is in the fourth position. If this matrix is being output by one of the extract_features routines then it almost certainly has the width in the third position and the height in the fourth position.
  8 Comments
Walter Roberson
Walter Roberson on 28 Jul 2017
num_space_columns = 5;
combined_output = outputs{1};
for K = 2 : length(outputs)
co_row = size(combined_output, 1);
this_extract = outputs{K};
te_row = size(this_extract, 1);
%match rows
if te_row < co_row
this_extract(end+1:co_row, :, :) = 1;
elseif te_row > co_row
combined_output(end+1:te_row, :, :) = 1;
co_row = te_row;
end
combined_output = [combined_output, ones(co_row, num_space_columns), this_extract];
end
stark iron
stark iron on 28 Jul 2017
Sir!Thank you so much for your great help @Walter Roberson

Sign in to comment.

More Answers (1)

KSSV
KSSV on 26 Jul 2017
Read about imwrite

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!