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...

1 次查看(过去 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