Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

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 vue (au cours des 30 derniers jours)
vishwas h s
vishwas h s le 15 Avr 2014
Clôturé : MATLAB Answer Bot le 20 Août 2021
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

Réponses (1)

Image Analyst
Image Analyst le 15 Avr 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.

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by