Good day,
I need help figuring out whats wrong with the code. Attached are the files required.
So the goal of the code is to translate any imformation from the attached image and input data collected into an excel file but for some reason, I have a problem with the transferring of data from MATLAB to Excel.
Any help would be appreciated.
Thank you.

 Réponse acceptée

Walter Roberson
Walter Roberson le 9 Mai 2019

1 vote

You grow numbers by one row for each subblock. Your line 68 extending numbers would fail of the number of digits in length(B) changed. You are constructing a char column vector that is mostly '0' characters, it appears.
Then each subblock, you write out all of the accumulate numbers to the rectangular area A1:AN40 even though it is only one column.
Ah... looking more closely that is not quite right. You initialize
number = [];
and later
numbers = [number ; num2str(length(B))];
This does not grow the array. You initialized number (no trailing 's') to [] so numbers (with trailing 's') will always become just num2str(length(B)) which will be a single character vector. And that is what you write out over all of A1:AN40 each time.
To accomodate different lengths you should be using a cell array of character vectors. For efficiency you should pre-allocate it to have the same number of elements as ca has. And you should leave the xlswrite() until after the nested for loops.
You should also pay more attention to all of those imshow() you have. They are erasing one another inside the same subplot, which is an expensive operation (image() instead of imshow() would do less in that regards.) There is no point in plotting those things only to erase them and immediately plot over them, since they will never be visible. Just plot the final image and the count.

7 commentaires

N/A
N/A le 11 Mai 2019
Good Day,
I tried what you suggested but can not seem to make it work.
Do you mind implementing your suggestion in the code above.
Thank you
Walter Roberson
Walter Roberson le 11 Mai 2019
I got it working, but the repeated calls to subplot were slowing it down quite badly. I managed to speed that up a lot, but I need more tuning on the positioning of the elements.
Question: do you really need a separate axes for each image, so that you can zoom and pan and use data cursor on each one individually? Each of the axes is very small, so you cannot see much if you do that. You could probably position items well by putting a whole bunch of images on the same axes.
What would work especially well is if it would be okay to just draw the original image, and then to draw grid lines showing the subgrids, and putting the count into the subgrid. The block numbers could either also be put into the subgrid, or the axes labels could be used to show marginal counts of block numbers.
N/A
N/A le 12 Mai 2019
Yes I do,
The goal is to take each figure represented on each small image and transfer that data into an Excel file while filling the empty blocks with 0.
Thank you so much for your help.
Walter Roberson
Walter Roberson le 12 Mai 2019
"Yes I do" what?
If the goal is just to do the counts and create an excel file, then it could be done in a small number of seconds if you skip all of the graphics. The current code with the 350 subplot() calls would take several tens of minutes, perhaps well over an hour, as the subplot() layout manager gets less and less efficient as the number of active subplot increases.
N/A
N/A le 12 Mai 2019
The initial goal of the code was to generate the segmented image and transfer the figures on each segmented image to an excel file.
I have succesfully generated the image but I'm having a hard time transferring the data generated to an excel file
Walter Roberson
Walter Roberson le 12 Mai 2019
Okay, since you don't really care about the display, I have enclosed a modified version that should handle the Excel part.
This version does not place some of the sub-images properly on the display, but is much faster than using subplot(). Since it is not the display you are interested in, there is no point in my getting the display perfect: this should be enough to show you that the analysis is working.
Note that this produces two figures. You were producing some images and writing over them and you produced a final image at a particular location which did not make any sense considering everying else being done, so I put that stuff into a separate figure. You will need to look for it specifically as it will be hidden behind the full-screen display of the sub-images.
N/A
N/A le 12 Mai 2019
Thank you so much

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by