Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

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 Ansicht (letzte 30 Tage)
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

Antworten (1)

Image Analyst
Image Analyst am 15 Apr. 2014
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.

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by