read pbin file to Matlab

조회 수: 4 (최근 30일)
Jack Daniels
Jack Daniels 2023년 1월 3일
답변: Manish 2024년 10월 23일
Dears,
how to Is there any example how to read "pbin" file into Matlab workspave?
Thank you.
  댓글 수: 2
Cameron
Cameron 2023년 1월 3일
Can you attach the file or an exmaple of the file? Without that it is difficult to answer.
Jack Daniels
Jack Daniels 2023년 1월 3일
편집: Jack Daniels 2023년 1월 3일
I've attached the file in *.pbin format - it should contain the image matrix. I'd like to read it and display (image) it...

댓글을 달려면 로그인하십시오.

답변 (1개)

Manish
Manish 2024년 10월 23일
Hi,
I understand that you want to read the ‘pbinfile, which contains an image data.
Here is the general approach to reading binary files and displaying them as images in MATLAB:
  • Start by using fopen to get your file ready. Just pass in the file name and the mode you want, like ‘r’ if you're planning to read.
  • Next, use the ‘fread’ to read the content of the file.
  • Finally, Close the file with help of ‘fclose’.
  • Visualise the image with help of ‘imshow’ function.
Here is the code sample to read the ‘pbin’ file which contains the image data:
filename = 'test1.pbin';
fileID = fopen(filename, 'rb');
% Adjust 'datatype' and [width, height] according to your file's specifications
width = 256;
height = 256;
dataType = 'uint8';
imageData = fread(fileID, [width, height], dataType);
fclose(fileID);
imshow(imageData, []);
You can refer to the documentations for the functions used: 
Hope this helps!

카테고리

Help CenterFile Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by