Image scale to a logarithmic scale x and y axis.

Hi
I have this code where I've (With some help from Matlab Community) made a script that reads a image and gives the different colorzones a number. Then I give the image a x and y axis, so that I can place a point with x and y coordinates, and it gives me which zone it is in. It works perfectly when my x and y axis are linear, but I need to have them logarithmic, both of them. But when I try to do it, I either get my image in a straight line with a slope of 45 degrees, or else I only get my axis logarithmic and not my image.
I've made a point [0.1 600] which should be in zone 7 if it works.
My image looks like this, because I offend find that i flips the picture, when I try to force the y axis to start from 0 in the bottum and 1000 in the top.
I've attached my code, its small and simple.
Hope someone can help me.

5 Comments

I have not looked at the code, but I noticed that you are talking about starting y at 0. If you are talking about log axes then those cannot start at 0 because log 0 is -inf

Hey Walter

No, my axis are:

[0.1 10], [1 1000]

But I cant scale my image to that.

And I can see in 2011 someone had the same problems as me, where you also tried to answer.

https://se.mathworks.com/matlabcentral/answers/174-how-to-display-images-with-log-axes

I have the same problem when I try to scale my image to a log scale, first it flips the image, and then then it exceeds the range that I have chosen. as illustrated in this picture. Where my axis ranges are x = [1 1000] and y = [0.1 10] (For the picture)

When I look at your code, it appears to me that you expect that particular axes coordinates will translate to different x or y coordinates depending upon whether the axes is set to log or linear. But look at the routine you are calling, axes2pix(): it does not take an axes as input, so it cannot possibly be querying whether the axes is log or linear.
When I test, I notice that there is no visual change for image() or imagesc() or imshow() when the axes is switched to log: the axes tick labels change but the image stays the same. To have the image change according to log or not, you need to use texturemapping to paint the image onto a surface. surf() and pcolor() [which is surf(), view(2)], and patch() can be used for that.
In any case, axes coordinates are going to be in data units, and those units get stretched or not in unison with log or not, so any given axes coordinate you query is going to map to the same image location. Unless, that is, that you consider it a feature that the image does not change when the axes is set to log... well, in that case, put log() of the coordinates through axes2pix()
Hey Walter
I'm totally new at this image conversion or texture-mapping, I'm trying to search on it on the internet but can't find a good guide or tutorial where I can learn it. Do you know a good guide or tutorial or do you mind writing the line of code in my script so it converts the image to a log scale and not just the axes? I can see a lot of people have been in here and looking, and since you are the only one writing I'm guessing they also need some help with this :). So I'm hoping you can help us "Newbies" with this image conversion to log log scales.
Your image is pseudocolor, so you could use warp()
You would just use planar coordinates.
Example with warp:
[I,map] = imread('forest.tif');
[X,Y] = meshgrid(1:size(I,1),1:size(I,2));
Z = zeros(size(X));
warp(X,Y,Z,I,map);
view(2)
set(gca,'xscale','log')

Sign in to comment.

Answers (0)

Categories

Find more on Images in Help Center and File Exchange

Asked:

on 7 Sep 2017

Commented:

on 11 Sep 2017

Community Treasure Hunt

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

Start Hunting!