이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
i know the scale but when i use imagesc function the image doesnt show me the right size of my spot. what am i doing wrong?
조회 수: 3 (최근 30일)
이전 댓글 표시
clear all;
close all;
Scale = 29.4/64; % Pixelscale of the image
[FileName, PathName] = uigetfile({'*.txt','PHASICS Txt File';'*.*', 'All Files (*.*)'},'Pick a file');
PhaseFile = fullfile(PathName,FileName);
PhaseData=importdata(PhaseFile,'\t'); % Read header less tab delimited txt file[Ny, Nx] = size(PhaseData);
[Nx, Ny] = size(PhaseData);
figure
imagesc(PhaseData); % Plot the data
채택된 답변
Image Analyst
2022년 1월 10일
PhaseData is structure. you need the Data field
theImage = PhaseData.Data;
댓글 수: 19
Image Analyst
2022년 1월 11일
When you browsed to a file and selected it, what was the name of that file? Please attach that file with the paperclip icon.
Image Analyst
2022년 1월 12일
This seems to work
Scale = 29.4/64; % Pixelscale of the image
% [FileName, PathName] = uigetfile({'*.txt','PHASICS Txt File';'*.*', 'All Files (*.*)'},'Pick a file');
% PhaseFile = fullfile(PathName,FileName);
PhaseFile = 'EXPORT PHA 170,0.5C,100,110,120 nJ, 20mmmin_0001.txt'
PhaseData=importdata(PhaseFile,'\t') % Read header less tab delimited txt file[Ny, Nx] = size(PhaseData);
[Nx, Ny] = size(PhaseData)
figure
imagesc(PhaseData); % Display the data
Is there still a problem?
Sobia Rehman
2022년 1월 12일
The height of my structure shown here is 30, although actual height is 10 and the scale along x axis and y axis is the pixel count? or micrometer etc?
Image Analyst
2022년 1월 12일
It's the pixel count. If you want the axes to show some other units, you can change the tick labels with 'XData' and 'YData' in imshow().
PhaseFile = 'EXPORT PHA 170,0.5C,100,110,120 nJ, 20mmmin_0001.txt'
PhaseData=importdata(PhaseFile,'\t'); % Read header less tab delimited txt file[Ny, Nx] = size(PhaseData);
[rows, columns] = size(PhaseData)
fovy = 10;
fovx = fovy * columns / rows
imshow(PhaseData, [], 'XData', [0, fovx], 'YData', [0, fovy]); % Display the data
caption = sprintf('Micrometers (%d pixels along x)', columns);
xlabel(caption)
caption = sprintf('Micrometers (%d pixels along y)', rows);
ylabel(caption)
axis ('on')
Sobia Rehman
2022년 1월 17일
Its working.
But this image shows it is 1.5 um but actually its around 14-15 um.
What can be the reason?
Image Analyst
2022년 1월 17일
I guess your scale (calibration factor) is wrong. See attached spatial calibration demo and integrate it into your code.
Sobia Rehman
2022년 1월 19일
Thanks Heaps!!
I will work on that but I want do one more task at the end. Once I get the image with exact dimentions I want to plot a grapgh for those dimentions (x and y) with third variable (Refractive index) in Imagesc to get a colored image at the end. Can you please guide how to assign x and y for dimentions and then tis specific plot?
Image Analyst
2022년 1월 19일
To get a line plot of x vs your third variable (let's call it z), you can use hold on. Then use rescale() to scale your third variable between 1 and the number of rows. Basically it would overlay a line plot over the image so you'd have z vs x and y would not be involved.
I'm not exactly sure what you want. So do you have a z value for every (x,y) pair? That would be an image or a surface. You can't put that over your original image without obscuring your original image. I suggest you use surf() or imshow() to show your z vs. (x,y) data.
Sobia Rehman
2022년 2월 15일
Hi again,
I want know one point.
I want to get the simplest method for this. If we have an image in pixel count and we know the scale of pixel and we want to assign the pixel along x axis as x cordinates and the pixel along y axis as y cordinates and then want to plot it according to the scale. what can be the simplest code for that?
Image Analyst
2022년 2월 15일
@Sobia Rehman not sure what you mean but let me reqord it more precisely and see if that's what you mean. You have a distance in pixels, and you have a spatial calibration factor in (real world units) per pixel. Now you want to plot the x and y, which you have in pixels, in real world units. Is that it? If so, lets say your units are millimeters and you have a variable called mmPerPixel, and vectors xInPixels and yInPixels in units of pixels. So you'd just convert and then plot
xInMm = xInPixels * mmPerPixel;
yInMm = yInPixels * mmPerPixel;
plot(xInMm, yInMm, 'b-', 'LineWidth', 2);
grid on;
xlabel('X in mm', 'FontSize', 20);
ylabel('Y in mm', 'FontSize', 20);
title('Y vs X in mm', 'FontSize', 20);
Sobia Rehman
2022년 2월 16일
I have attavhed two files.
when i start with
clear all;
close all;
Scale = 29.4/64; % Pixelscale of the image
[FileName, PathName] = uigetfile({'*.txt','PHASICS Txt File';'*.*', 'All Files (*.*)'},'Pick a file');
PhaseFile = fullfile(PathName,FileName);
PhaseData=importdata(PhaseFile,'\t');
The above lines of the code is to call the file and scale is mentioned.
Then I start with
[Nx, Ny] = size(PhaseData); This is to find the number of rows and columns
If i write next in code
imagesc(PhaseData); This displays me the image of PhaseData and along x axis and y axis numbers are shown which is actually xcordinates and ycordinates in pixel count. My question is how to assign the x cordinates and y cordinates in pixels first and then convert it to mm according to the scale.
In last comment you have mentioned xInPixels but i dont know how to assign values to this xInPixels.
I hope my question is clear. I am stuck with this issue from many days. It will be great if you can help me out from this.
Many Thanks
Image Analyst
2022년 2월 16일
You can use imshow():
XData = [0, Nx] * Scale;
YData = [0, Ny] * Scale;
imshow(PhaseData, 'XData', XData, 'YData', YData);
axis('on', 'image')
This will make the axis read out in calibrated, real world units instead of pixels.
Sobia Rehman
2022년 2월 16일
This gives me an image like this
Can you please have a look. Thanks for your time and efforts.
Sobia Rehman
2022년 2월 16일
Finally I have got this using this code
clear all;
close all;
%nBulk = 1.4536;
Scale = 29.4/64; % Pixelscale of the image
[FileName, PathName] = uigetfile({'*.txt','PHASICS Txt File';'*.*', 'All Files (*.*)'},'Pick a file');
PhaseFile = fullfile(PathName,FileName);
PhaseData=importdata(PhaseFile,'\t'); % Read header less tab delimited txt file[Ny, Nx] = size(PhaseData);
[Nx, Ny] = size(PhaseData);
XData = [0, Nx] * Scale;
YData = [0, Ny] * Scale;
imagesc(XData, YData, PhaseData);
This shows me the picture now in real life units.
Thanks heaps for your help.
Image Analyst
2022년 2월 16일
You must have floating point image outside the range of 0-1. So try it this way:
XData = [0, Nx] * Scale;
YData = [0, Ny] * Scale;
imshow(PhaseData, [], 'XData', XData, 'YData', YData);
axis('on', 'image')
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Convert Image Type에 대해 자세히 알아보기
태그
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)