How I can read image with PPM format without imread and design PPM reader ?
이전 댓글 표시
I want to read test.ppm image without imread and design PPM reader and open it with fopen and extract data from it after that show it with imshow.
Can you help me?
댓글 수: 7
DGM
2021년 11월 25일
Find the format specification:
Read the file with fread() or something
split the header, etc from the raster data
based on the information in the header, do whatever needs to be done to convert the raster data into a MxNx3 numeric array.
elma ozge
2021년 11월 26일
Image Analyst
2021년 11월 26일
Why do you not want to use the built-in imread() and try to write your own ppm reader (or actually have us write it for you)? What's wrong with using imread()????
elma ozge
2021년 11월 26일
Image Analyst
2021년 11월 26일
We know that. You already said that earlier. I was curious as to why.
And DGM already gave you a start, so just continue on with that. You accepted it (thanks), so I guess that's what you're planning on.
elma ozge
2021년 11월 26일
Walter Roberson
2021년 11월 26일
What is the reason that you cannot use imread() ?
채택된 답변
추가 답변 (2개)
Walter Roberson
2021년 11월 25일
1 개 추천
fopen the file and read it as a series of uint8. fclose(). Now use loadlibrary() to make a call to the libnetpbm library to decode the uint8 into an image.
By the way, is it a P3 or P6?
댓글 수: 2
elma ozge
2021년 11월 26일
Walter Roberson
2021년 11월 26일
PPM files do not all have exactly the same layout. The very first item inside a PPM file gives information about which of the formats the rest of the file is in. Two of the most common formats are known by the codes P3 and P6.
If you need to be able to handle all possible PPM files, then you have to do notably more work than if you only have to handle one particular kind of PPM file.
카테고리
도움말 센터 및 File Exchange에서 Convert Image Type에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!