I am having Permission Issue with imwrite.

8 views (last 30 days)
Hi all,
I am getting the following error while trying to run my SPIHT demo:
-------------------------------------------------------------------------------------
??? Error using ==> imwrite at 397
Can't open file "C:\Program Files\MATLAB\R2008a\work\hiten2\Transmission on channel1 at a rate of1 bpp gives a PSNR of28.34 db Block size
=32.bmp" for writing.
You may not have write permission.
Error in ==> func_SPIHT_ulti at 401
imwrite(img_rec, gray(256), imagefile, 'bmp')
--------------------------------------------------------------------------------------
I am including the MATLAB code associated with this error here. Can anyone please help me to get around with this error..
fprintf('\n\n----------- PSNR analysis ----------------\n');
imwrite(img_rec, gray(256), outfilename, 'bmp');
Q = 255;
MSE = sum(sum((img_rec-Orig_I).^2))/nRow / nColumn;
PSNR = 10*log10(Q*Q/MSE) % in dB
fprintf('\nThe psnr performance is %.2f dB\n\n', PSNR);
imagefile = strcat('C:\Program Files\MATLAB\R2008a\work\hiten2', '\','Transmission on channel ', num2str(m),' at a rate of ' ,num2str(rate),' bpp gives a PSNR of ', num2str((PSNR), '%10.2f'), ' db Block size = ', num2str(BlockSize),'.bmp');
imwrite(img_rec, gray(256), imagefile, 'bmp')
channel(m)= m;
MSE_vctr(m) = MSE;
PSNR_vctr(m) = PSNR;

Answers (2)

Image Analyst
Image Analyst on 9 Dec 2013
You're probably using Windows 7. Unlike Windows XP, Windows 7 does not allow you to write to locations under the C:\Program Files folder without certain actions. You'll have to pick another folder, like C:\users\Sabbir\Documents or someplace. If you really need to save it there the only thing I can suggest trying is to run MATLAB as administrator, but even then the UAC (User Account Control) may pop up asking if you want to give MATLAB permission to carry out the write operation. I've just moved all my data (m-files, images, etc.) to a secondary internal hard drive so I no longer have such problems.

Azzi Abdelmalek
Azzi Abdelmalek on 9 Dec 2013
Edited: Azzi Abdelmalek on 9 Dec 2013
Change the folder to D:\... or c:\users\...

Categories

Find more on Denoising and Compression in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!