How to convert .oct file into jpeg format

I am trying to convert image obtained from optical coherence tomography (.oct file) into jpeg format. The code used is below:
% inputFolder = fileparts(which('cameraman.tif')) % Determine where demo folder is (works with all versions).
inputFolder = fullfile(pwd, 'D:\MiddleEar\Matlab');
filePattern = fullfile(inputFolder, '*.oct');
% Get list of all BMP files in input folder
octFiles = dir(filePattern);
% Create the output folder:
outputFolder = fullfile(pwd, 'D:\MiddleEar\Matlab Folder\JPEG DATA');
if ~exist(outputFolder, 'dir')
mkdir(outputFolder);
end
figure;
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Loop over all oct files, making a jpg version
% of them in the output folder.
for k = 1 : length(octFiles)
% Read in .oct file
baseFileName = octFiles(k).name;
fullFileNameInput = fullfile(inputFolder, baseFileName);
rgbImage = imread(fullFileNameInput);
subplot(1, 2, 1);
imshow(rgbImage);
title('Original image', 'FontSize', 30);
drawnow;
% Prepare output file name
fullFileNameOutput = fullfile(outputFolder, baseFileName);
% Converts to JPEG and gives it the .jpg extension
fullFileNameOutput = strrep(lower(fullFileNameOutput), '.oct', 'jpg')
imwrite(rgbImage,fullFileNameOutput);
% Reloads it in a JPEG format to see how bad the compression artifacts are.
rgbImage = imread(fullFileNameOutput);
subplot(1, 2, 2);
imshow(rgbImage);
title('Recalled JPG image', 'FontSize', 30);
drawnow;
pause(1);
end
% Open Windows Explorer to the output folder:
winopen(outputFolder);
I am getting the following error message:
Error using mkdir
The filename, directory name, or volume label syntax is incorrect.
Error in test1 (line 9)
mkdir(outputFolder);
Any help with the code would be very much appreciated. Thank you.

Réponses (1)

Walter Roberson
Walter Roberson le 25 Juin 2019

0 votes

pwd will be a fully qualified path. When you fullfile with pwd as the first parameter and D: as the second you are concatenating the two together which will result in a file name that starts with some drive specification and then later has a second drive in it. Windows does not permit two drive specifications in a single file name.

7 commentaires

Warid Islam
Warid Islam le 26 Juin 2019
Hi Walter,
I tried but couldn't convert the .oct files into jpeg. It would be very helpful for me if you can give me some idea about how to solve the issue. Thank you.
Best Regards
Warid Islam
Walter Roberson
Walter Roberson le 26 Juin 2019
oct files are not supported by imread. They are a custom file format. See https://www.mathworks.com/matlabcentral/answers/242474-how-to-open-oct-file-in-matlab#answer_217904
Warid Islam
Warid Islam le 27 Juin 2019
Hi Walter,
I tried but I am unable to solve the issue. Do you have any other tutorials or codes from where I can take some ideas on how to obtain a solution. Thank you.
Best Regads
Warid Islam
Walter Roberson
Walter Roberson le 28 Juin 2019
No, I do not have any other tutorials or codes from where you can take some ideas on how to obtain a solution.
The file format is proprietary. Bioptigen will apparently supply MATLAB code to its customers, but I am not a customer of theirs. Tom Wright implemented in Python, and you can call Python from MATLAB.
Warid Islam
Warid Islam le 1 Juil 2019
Hi Walter,
Thank you for the suggestion. Unfortunately, the python file that Tom wrote cannot be read in github. It is displaying an error message. May be the file is not there anymore in github.
Thank you.
Warid Islam
sudo git clone https://github.com/tomwright01/iowa_oct_analysis.git
worked for me.
William Warriner
William Warriner le 10 Fév 2020
Modifié(e) : William Warriner le 10 Fév 2020
I also was looking for something along these lines for reading Bioptigen files. Thanks for posting!
To anyone else reading this after me, use the following commands to find it in the repo after cloning.
git fetch --tags --all
git checkout tags/1.0.0
It is the file "App/readBioptigenOct.py"

Connectez-vous pour commenter.

Catégories

En savoir plus sur Environment and Settings dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by