MATLAB Answers

.dat file image generation and analysis

62 ビュー (過去 30 日間)
David Comiskey
David Comiskey 2019 年 9 月 9 日
コメント済み: Neuropragmatist 2019 年 9 月 9 日
I have a current need to undertake image analysis and have the following query. I have .dat file containing an industrial X-Ray image with 16 bit greyscale range values. The .dat file contains values for each pixel in the 250 x 439 image size. My question, as a non-user and novice in this area, is if Matlab can be used to create a visual image from the .dat file and be used for analysis? Any links or suggested learning documentation in this area would be most welcome.

  0 件のコメント

サインインしてコメントする。

採用された回答

Neuropragmatist
Neuropragmatist 2019 年 9 月 9 日
Matlab has countless ways to visualise images loaded into the workspace.
The problem with your file is that .dat sounds like a generic file type and Matlab won't know how to load it. Do you know if the file has an underlying file type like .tiff? Or can you convert your .dat file to an image or text file? What program do you normally use to view your .dat files?
If you upload one of your files we might be able to take a closer look.
M.

  8 件のコメント

表示 5 件の古いコメント
Neuropragmatist
Neuropragmatist 2019 年 9 月 9 日
OK, I was expecting to have to go digging around but the first thing I tried actually worked. I just passed the file to Matlab's inbuilt 'importdata' function and it does fine to load your file. From there plotting it is really easy:
img = importdata('Ulster Univ Cladding _Insul Samples_20_summed.dat');
% img is a matrix that seems to just be your image
% some plotting routines
figure
subplot(2,2,1)
imagesc(img) % imagesc is the easiest and one of the most commonly used
daspect([1 1 1])
colormap(gca,gray) % using a gray colormap for grayscale makes sense
caxis([intmin('uint16') intmax('uint16')]) % I scale the colormap for what should be
% the min and max value of your image (min possible uint16 value to max possible uint16 value)
title('imagesc, gray')
subplot(2,2,2)
imagesc(img)
daspect([1 1 1])
colormap(gca,jet)
title('imagesc, jet') % same thing as above with the more fondly used jet colormap
caxis([intmin('uint16') intmax('uint16')])
subplot(2,2,3)
imshow(img,[intmin('uint16') intmax('uint16')]) % imshow is a similar function
daspect([1 1 1])
title('imshow for uint16')
I've included just a couple of different ways to plot the data here, I'll let you explore around for what suits you best.
Hope this helps,
M.
Edit: also I just remembered that you mentioned image analysis. In the code above 'img' is a matrix that contains your x-ray image. In the above code I have just plotted it graphically, but you can also apply image analysis techniques to this matrix if you like:
David Comiskey
David Comiskey 2019 年 9 月 9 日
Thanks so much, that is perfect. It gives me confidence that this is the way to go. Time to get trained up in Matlab!
Neuropragmatist
Neuropragmatist 2019 年 9 月 9 日
Cool, glad to help.
M.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by