Yes, this is possible - as Mensur said above, you will need to get the letter heights as accurately as possible. If you have a vector graphics image, you can extract the actual heights from it using any vector graphics software. If you just have a rasterized image (e.g. PNG, JPEG, etc.), you can still do it by using letter height in pixels, although it's a little less accurate, with the accuracy being proportional to the resolution.
However, you don't actually need to do the reverse of the information content calculation (measured in bits) - this value is only related to the height of the whole stack of nucleotides at a particular position, not the relative heights of nucleotides within the stack. In fact, the relative heights of nucleotides within the stack are the relative frequencies of that letter as found in the position-weighted matrix.
So to make up some numbers to illustrate the point, let's say you have a sequence logo, and at position 1, the heights are:
A = 100 pixels
C = 10 pixels
T = 25 pixels
G = 37 pixels
Sum = 100 + 10 + 25 + 37 = 172
The relative frequencies would be:
A = 100/172 = 0.581
C = 10/172 = 0.058
T = 25/172 = 0.145
G = 37/172 = 0.215
And those would form the values in your position-weighted matrix for the column at position 1.
Again though, this gets inaccurate if the number of pixels is low, so you want as high of resolution as possible (assuming you don't have vector graphics files)! Hope this helps :)
I managed to run the original code at https://github.com/zY2EZHVByG/Logo2PWM in MATLAB R2024b.
You need to do add the following add-ons: Image Processing Toolbox, Signal Processing Toolbox and Statistics and Machine Learning Toolbox (in my case all version 24.2).
You also need to clone the source with:
In MATLAB you need to add the full path to the
Logo2PWM/source_code/functions
to the search path and finally call the conversion function from the Command window as followsTo give you an idea, from the logo on panel A I obtained the following CSV matrix: