現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
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!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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 (한국어)