read pbin file to Matlab
4 次查看(过去 30 天)
显示 更早的评论
Dears,
how to Is there any example how to read "pbin" file into Matlab workspave?
Thank you.
2 个评论
Cameron
2023-1-3
Can you attach the file or an exmaple of the file? Without that it is difficult to answer.
回答(1 个)
Manish
2024-10-23,11:00
Hi,
I understand that you want to read the ‘pbin’ file, 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:
- fopen: https://www.mathworks.com/help/matlab/ref/fopen.html
- fread: https://www.mathworks.com/help/matlab/ref/fread.html
- fclose: https://www.mathworks.com/help/matlab/ref/fclose.html
- imshow: https://www.mathworks.com/help/matlab/ref/imshow.html
Hope this helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing and Computer Vision 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!