Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

hi all.. i am writing a program to convert image to text... but i am getting an error " Invalid file identifier. Use fopen to generate a valid file identifier."...can pls get me out of it...i am attaching the code with it...

조회 수: 2 (최근 30일)
clc; clear all; img=imread('F:\TEST PICTURES\car.jpg'); %Read a Gray image from workspace img=rgb2gray(img); [r c] = size(img); img=imnoise(img,'salt & pepper',0.50); img=uint8(img); img_double=double(img); k=img_double'; %Transpose the matrix m=reshape(k,r*c,1); %Pixels are reshaped into 262144 rows with single column fid=fopen('c:\lena512_50.txt', 'w'); %Open the file outfile.txt for writing purpose for j=1:65536 z(j)=m(j); end fprintf(fid, '%x\n', z'); %Write hex formated data to file id fclose('all'); imshow(img); %Display the image for which text equivalent is generated

답변 (1개)

Image Analyst
Image Analyst 2014년 4월 15일
What is the value of fid? Where is your code that checks the value of fid? Don't you want to write robust code that checks for things like failures of certain functions?
Why do you want to write all the pixel values of out to a text file anyway? And why are you naming the values from car.jpg as "lena512_50.txt"???? That seems like a deceptive name.

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by