Borrar filtros
Borrar filtros

Image axis label reshape

1 visualización (últimos 30 días)
Golam Chowdhury
Golam Chowdhury el 28 de Feb. de 2017
Comentada: Adam el 28 de Feb. de 2017
I have an (mxn) image. When I use interpolation and display the image to the original size (mxn), the X and Y ticks are off. How do I fix it?
For example: 1.) I is an (mxn) image. 2.) [mp, np] = size( interp2(I, 4) ); 3) How do I do this part? imageSizeRadial is the size of the object in radial direction. Let's say it is 0.7 mm.
ax.XTick = (where_to_start : .35 : imageSizeRadial) * floor(np/imageSizeRadial); ax.XTickLabel = {10, 360, 710};
we record the image at 10 micro-meter. Hence the first tick should be 10 micrometer.The problem is that he tick is below the surface.
Same applies to the Y label
Please see the attached figure.
<<
>>
I would like to place a tick in .010 mm, 0.36 mm, 0.71 mm.
  2 comentarios
Vandana Rajan
Vandana Rajan el 28 de Feb. de 2017
Hi,
Can you put this pic as an attachment? The details are not really visible.
Golam Chowdhury
Golam Chowdhury el 28 de Feb. de 2017
Hi Rajan, I have placed a simplified code. hopefully this resolves the query. Thanks.

Iniciar sesión para comentar.

Respuestas (1)

Adam
Adam el 28 de Feb. de 2017
If you use the
imagesc( hAxes, x, y, C )
form of plotting the image then you can tell it what the x range and y range of your image is so that even if you interpolated the actual data to e.g. 1000 x 1000 you can tell it that the x data is [0 100] and the y data is [0 50] or whatever you want - i.e. you can just give it your original uninterpolated image sizes, assuming they were correct. I'm not really understanding from your question what exactly is wrong and what it should look like. You seem to be assuming bits and pieces of domain knowledge in your question rather than just pure matlab image plotting
  2 comentarios
Golam Chowdhury
Golam Chowdhury el 28 de Feb. de 2017
Hi Adam, Thank you for the answer. I have created a simplified object to illustrate the problem. I am not good at conveying the problem. Sorry about it. In figure 1, the x and y tick starts at beginning of image. Here, the image is 0.7mm by 1.5mm. If image records data at 10 microns, the image should Mark form (0.01mm to 0.71 mm ) by (0.01 mm to 1.51 mm). however, please note that the image is still 0.7 mm by 1.5 mm.
Now, when I tried interpolate it, the x and y tick marks got shifted to right and below.
here is very just a scaled down code.
clc clear close all
%% This part is okay.
nDepth = 76; nPlanar = 36; startOffset = 0.01; xLabelSpacingMultiplier = 50; yLabelSpacingMultiplier = 50; imageSizeRadial = 0.7 + monteCarloStartOffset; % mm imageSizeDepth = 1.5 + monteCarloStartOffset; % mm
obj1_depth = 10; % object location x-coordinate (grid) obj1_planar = 15; % object location y-coordinate (grid) obj1_depth_size = 2; % size of object (grid) obj1_planar_size = 2; % size of object (grid)
% Define Object obj = zeros(nDepth, nPlanar); obj(obj1_depth : obj1_depth + (obj1_depth_size - 1) , obj1_planar : obj1_planar + (obj1_planar_size - 1) ) = 1;
figure(1) imagesc(obj), colorbar axis equal axis tight
ax = gca; ax.XTick = []; ax.YTick = [];
ax.XTick = (startOffset : .35 : imageSizeRadial) * xLabelSpacingMultiplier; ax.XTickLabel = {num2str(startOffset*1e3), (.35 + startOffset)*1e3, num2str((imageSizeRadial)*1e3)};
ax.YTick = (startOffset : .25 : imageSizeDepth) * yLabelSpacingMultiplier; ax.YTickLabel = {num2str(startOffset*1e3), (.25 + startOffset)*1e3, (.50 + startOffset)*1e3, (.75 + startOffset)*1e3, (1.0 + startOffset)*1e3, (1.25 + startOffset)*1e3, num2str((imageSizeDepth)*1e3)};
set(gca,'xaxisLocation','bottom')
%% Now I tried to interpolate the object
figure(2) imagesc( interp2(obj, 4) ) colorbar axis equal axis tight
ax = gca; ax.XTick = []; ax.YTick = [];
[m, n] = size( interp2(obj, 4) );
ax.XTick = (startOffset : .35 : imageSizeRadial ) * floor(n/imageSizeRadial); ax.XTickLabel = {num2str(startOffset*1e3), (.35 + startOffset)*1e3, num2str((imageSizeRadial)*1e3)};
ax.YTick = (startOffset : .25 : imageSizeDepth) * floor(m/imageSizeDepth); ax.YTickLabel = {num2str(startOffset*1e3), (.25 + startOffset)*1e3, (.50 + startOffset)*1e3, (.75 + startOffset)*1e3, (1.0 + startOffset)*1e3, (1.25 + startOffset)*1e3, num2str((imageSizeDepth)*1e3)};
set(gca,'xaxisLocation','bottom')
%% COMMENT: Problem is in FIGURE 2, the x and y ticks are shifted to the RIGHT. It should be like in FIGURE 1.
Adam
Adam el 28 de Feb. de 2017
I can't run your code as I don't have 'monteCarloStartOffset', amongst possibly other things.
Did you try giving the xData and yData to imagesc though? The first tick in that case should be at whatever you tell it is the xData minimum and the same for yData.

Iniciar sesión para comentar.

Categorías

Más información sobre Graphics Object Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by