convert table to image
Show older comments
Hello everyone,
I have a table size 175x81 .each column is feature.
my question is that .İneed to convert this to image but i dont know how to do it ?
3 Comments
hakan
on 20 May 2023
Moved: Walter Roberson
on 20 May 2023
Walter Roberson
on 20 May 2023
You have 81 columns so are you wanting each image to be 1x81 or 3x27 or 9x9 or 27x3 or 81x1?
The id does not appear to be a feature so perhaps you want a 5x16 or 8x10 image?
Image Analyst
on 21 May 2023
It does not make sense for each row to be an image since the columns represent totally different things. Do you want the columns to be images, like @Walter Roberson said? If so, which columns? Probably not all 81 of them (for 81 different images), but maybe. How do you want to take the 175 elements in each column and make a 2-D image out of them? Exactly how many rows and columns do you want it to have?
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
Answers (1)
chicken vector
on 18 May 2023
Edited: chicken vector
on 18 May 2023
% Define example table:
tab = table(rand(100));
% Convert table to array:
arr = table2array(tab);
% Display array:
imshow(arr);
9 Comments
Walter Roberson
on 18 May 2023
Note that the table entries are floating point and include values over 100. You would want
imshow(arr, [])
or
imagesc(arr)
or explicitly call rescale with minimum 0 and maximum 1 and setting 'InputMin' 'InputMax' so that you can force a consistent scaling.
chicken vector
on 18 May 2023
Or:
imshow(arr/max(arr,'all'));
Walter Roberson
on 18 May 2023
True. The image of data that we are shown does not include anything less than 0.623 but probably 0 is a good enough approximation for that considering the scale of the other values.
The image of data that we are shown does not include any negatives, and when people talk about "features" they often mentally exclude negative values, but there are varieties of features that are potentially negative.
chicken vector
on 18 May 2023
Edited: chicken vector
on 18 May 2023
You can further normalise with
nArr = arr - min(arr, [], 'all');
imshow(nArr/max(nArr, 'all'))
Dividing subtraction and division allows for more flexibility, throwing an error only for arrays of zeros.
chicken vector
on 18 May 2023
Edited: chicken vector
on 18 May 2023
For the sake of completeness:
nArr = arr - min(arr, [], 'all');
imshow(nArr/(max(nArr, 'all') + ~any(nArr)))
Walter Roberson
on 18 May 2023
chicken vector
on 18 May 2023
Most definitely yes!
Walter Roberson
on 18 May 2023
I find that people often do not pay as much attention as they should to repeatability of color when using rescale() or imagesc() or imshow([]) . With the default parameters, or default caxis() / clim() , the mapping of particular numeric value to color can change if the lower bound of the data or the upper bound of the data change.
So for example a temperature map might show 25C as being moderately comfortable one time, but if the low for the next map increased, then 25C might be at a lower portion relative to low-to-high for the day so 25C might show up with colors associated with cooler values when looking at two images side-by-side (and not paying close attention to any colorbars.)
I know I've been sloppy on this aspect many many times myself, but when I am generating graphics that might end up being compared, I try to remember to use scaling relative to absolute ranges so that the colors have some consistent meaning.
In this particular case, though, where numeric values for "features" are being implicitly compared regardless of the fact that the features might have no mathematical relationship to each other, then it probably does not matter. I'm not sure that there is any meaningful coloration in this situation.
chicken vector
on 19 May 2023
I most definetly agree.
If you need multiple plots when you deal with physical variables, in my opinion, is always good practice to set some meaningful and constant boundaries for the scaling operation.
Dealing usually with modelling problems, I have learnd this the hard way. I would even say the hardest since I mostly use colorbars...
Categories
Find more on Data Distribution Plots 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!