From c046df11dec33386ce2398905520102b678904ef Mon Sep 17 00:00:00 2001 From: "Ayush Jamdar (Non-OVT)" Date: Mon, 14 Jul 2025 14:10:40 -0700 Subject: [PATCH 1/6] Initial commit: raw working files --- utilities/pbrt/pbrt-v4/piEXR2ISET.m | 16 ++++++++++------ utilities/pbrt/pbrt-v4/piEXR2Mat.m | 19 +++++++++++++++---- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/utilities/pbrt/pbrt-v4/piEXR2ISET.m b/utilities/pbrt/pbrt-v4/piEXR2ISET.m index 63b2e12..1f2f7e7 100644 --- a/utilities/pbrt/pbrt-v4/piEXR2ISET.m +++ b/utilities/pbrt/pbrt-v4/piEXR2ISET.m @@ -94,7 +94,7 @@ nn = nn+1; end try - % New format + % New format: Perhaps they mean MATLAB's exrread()? energy = exrread(inputFile,Channels = radianceChannels); catch % keep the old format @@ -109,13 +109,17 @@ case {'depth', 'zdepth'} info = exrinfo(inputFile); - channelNames = info.ChannelInfo.Properties.RowNames; - if contains('P.X',channelNames) + % disp(info); + % fieldnames(info) + channelNames = info.channels; + if any(strcmp('P.X', channelNames)) % Modern naming for X,Y,Z coordinates - coordinates = exrread(inputFile,Channels=["P.X","P.Y","P.Z"]); - elseif contains('Px',channelNames) + % coordinates = exrread(inputFile,Channels=["P.X","P.Y","P.Z"]); + coordinates = exrread(inputFile); + elseif any(strcmp('Px', channelNames)) % Historical naming - coordinates = exrread(inputFile,Channels=["Px","Py","Pz"]); + % coordinates = exrread(inputFile,Channels=["Px","Py","Pz"]); + coordinates = exrread(inputFile); else warning('No X,Y,Z channels found. Returning.'); return; diff --git a/utilities/pbrt/pbrt-v4/piEXR2Mat.m b/utilities/pbrt/pbrt-v4/piEXR2Mat.m index 32d8abd..ff995cf 100644 --- a/utilities/pbrt/pbrt-v4/piEXR2Mat.m +++ b/utilities/pbrt/pbrt-v4/piEXR2Mat.m @@ -18,8 +18,20 @@ % dockerWrapper Support, D. Cardinal, 2022 % +% Below lines are added for Octave compatiblity +% Should ideally support runs from both Octave and MATLAB + +% Determine if we're in Octave +isOctave = exist('OCTAVE_VERSION', 'builtin') ~= 0; + +% Check if MATLAB exrread() is available +hasBuiltinExrread = false; +if ~isOctave && exist('isMATLABReleaseOlderThan', 'file') > 0 + hasBuiltinExrread = ~isMATLABReleaseOlderThan('R2022b'); +end + % tic -if exist('isMATLABReleaseOlderThan','file') > 0 && ~isMATLABReleaseOlderThan('R2022b') +if hasBuiltinExrread % Use Matlab builtin exrread from the image toolbox % Matlab included exrread() in 2022b. We included exread() in @@ -48,8 +60,7 @@ data = exrread(inputFile, Channels = channels); return; -elseif isfile(fullfile(isetRootPath,'imgproc','openexr','exrread.m')) - +elseif isfile(fullfile(isetRootPath,'imgproc','openexr','exrreadchannels.mex')) % Use the exrread() from ISETCam. if strcmpi(channelname,'radiance') @@ -95,7 +106,7 @@ if status disp(result); - error('EXR to Binary conversion failed.') + error('EXR to Binary conversion failed.'); end allFiles = dir([indir,sprintf('/%s_*',fname)]); fileList = []; From 16f1ceaf03934fcf4ebb0e2da220dd7ef81f9a79 Mon Sep 17 00:00:00 2001 From: "Ayush Jamdar (Non-OVT)" Date: Tue, 15 Jul 2025 12:06:09 -0700 Subject: [PATCH 2/6] update readme to indicate octave support --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index dc3d848..0698e57 100644 --- a/README.md +++ b/README.md @@ -20,3 +20,9 @@ To see some examples, have a look at the tutorial directory. If you want to read Note: This repository was formerly ISET3d-v4, pbrt2iset, and before that we relied on RenderToolbox4. ISET3d was originally developed in Brian Wandell's [Vistalab group](https://vistalab.stanford.edu/) at [Stanford University](stanford.edu), along with co-contributors from other research institutions and industry. + +## Octave Support +- July 14, 2025: Ayush Jamdar at Omnivision Technologies Inc. +- The EXR readers come from OpenEXR and accept only the filename as input. +- We still rely on `.mex` exr io functions but those are built using `mkoctfile`. See `isetcam/imgproc/openexr` +- We have tested `isethdrsensor/scripts/fullSimulation.m` on examples from the ISET HDR dataset. From 548bbd4b094d007e1b9d1768f4058855306c945b Mon Sep 17 00:00:00 2001 From: "Ayush Jamdar (Non-OVT)" Date: Thu, 24 Jul 2025 11:05:02 -0700 Subject: [PATCH 3/6] Update comments and Readme --- README.md | 4 ++-- utilities/pbrt/pbrt-v4/piEXR2Mat.m | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0698e57..a80dbab 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Note: This repository was formerly ISET3d-v4, pbrt2iset, and before that we reli ISET3d was originally developed in Brian Wandell's [Vistalab group](https://vistalab.stanford.edu/) at [Stanford University](stanford.edu), along with co-contributors from other research institutions and industry. ## Octave Support -- July 14, 2025: Ayush Jamdar at Omnivision Technologies Inc. +- July 14, 2025: Ayush Jamdar. - The EXR readers come from OpenEXR and accept only the filename as input. - We still rely on `.mex` exr io functions but those are built using `mkoctfile`. See `isetcam/imgproc/openexr` -- We have tested `isethdrsensor/scripts/fullSimulation.m` on examples from the ISET HDR dataset. +- We have tested `isethdrsensor/scripts/fullSimulation.m` on examples from the ISET HDR dataset using Octave 6.4.0. diff --git a/utilities/pbrt/pbrt-v4/piEXR2Mat.m b/utilities/pbrt/pbrt-v4/piEXR2Mat.m index ff995cf..25b5894 100644 --- a/utilities/pbrt/pbrt-v4/piEXR2Mat.m +++ b/utilities/pbrt/pbrt-v4/piEXR2Mat.m @@ -61,7 +61,10 @@ return; elseif isfile(fullfile(isetRootPath,'imgproc','openexr','exrreadchannels.mex')) - % Use the exrread() from ISETCam. + % If Matlab's exrread() isn't available, the user must be using + % openexr's exrread() (either from older Matlab or Octave) + % In this case, the mex file should exist + % Note that this file reader uses arguments different from Matlab's if strcmpi(channelname,'radiance') channels = cell(1,31); From 572b70e6374cd8a7df44d3b7e63045c466060157 Mon Sep 17 00:00:00 2001 From: "Ayush Jamdar (Non-OVT)" Date: Thu, 24 Jul 2025 12:25:48 -0700 Subject: [PATCH 4/6] Update Readme to include env instructions --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a80dbab..6fb6d9a 100644 --- a/README.md +++ b/README.md @@ -26,3 +26,4 @@ ISET3d was originally developed in Brian Wandell's [Vistalab group](https://vist - The EXR readers come from OpenEXR and accept only the filename as input. - We still rely on `.mex` exr io functions but those are built using `mkoctfile`. See `isetcam/imgproc/openexr` - We have tested `isethdrsensor/scripts/fullSimulation.m` on examples from the ISET HDR dataset using Octave 6.4.0. +- Refer to `isetcam/README.md` for Octave and Conda environment packages. From d6b9a542c5f56a80d8a9cf6c0a91b667ecc9e114 Mon Sep 17 00:00:00 2001 From: "Ayush Jamdar (Non-OVT)" Date: Mon, 4 Aug 2025 10:32:07 -0700 Subject: [PATCH 5/6] Added isOctave.m --- utilities/isOctave.m | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 utilities/isOctave.m diff --git a/utilities/isOctave.m b/utilities/isOctave.m new file mode 100644 index 0000000..f7f1b70 --- /dev/null +++ b/utilities/isOctave.m @@ -0,0 +1,14 @@ +% Test if running in Octave + +% This function will be called whenever code differs between +% Matlab and Octave, with the goal to extend ISET support + +function retval = isOctave + persistent cacheval; + if isempty (cacheval) + cacheval = (exist ("OCTAVE_VERSION", "builtin") > 0); + end + retval = cacheval; +end + + From e4427f038af9a43befa0d8bc134832577fcee50a Mon Sep 17 00:00:00 2001 From: "Ayush Jamdar (Non-OVT)" Date: Mon, 4 Aug 2025 10:48:39 -0700 Subject: [PATCH 6/6] Added isOctave check --- README.md | 1 + utilities/pbrt/pbrt-v4/piEXR2ISET.m | 41 ++++++++++++++++++----------- utilities/pbrt/pbrt-v4/piEXR2Mat.m | 9 ++----- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 6fb6d9a..174ef1a 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ ISET3d was originally developed in Brian Wandell's [Vistalab group](https://vist ## Octave Support - July 14, 2025: Ayush Jamdar. +- New: A function `isOctave` tests if code is being run in Octave and uses modified code accordingly. - The EXR readers come from OpenEXR and accept only the filename as input. - We still rely on `.mex` exr io functions but those are built using `mkoctfile`. See `isetcam/imgproc/openexr` - We have tested `isethdrsensor/scripts/fullSimulation.m` on examples from the ISET HDR dataset using Octave 6.4.0. diff --git a/utilities/pbrt/pbrt-v4/piEXR2ISET.m b/utilities/pbrt/pbrt-v4/piEXR2ISET.m index 1f2f7e7..f113c04 100644 --- a/utilities/pbrt/pbrt-v4/piEXR2ISET.m +++ b/utilities/pbrt/pbrt-v4/piEXR2ISET.m @@ -94,7 +94,7 @@ nn = nn+1; end try - % New format: Perhaps they mean MATLAB's exrread()? + % New format: exrread() either from Matlab or Openexr energy = exrread(inputFile,Channels = radianceChannels); catch % keep the old format @@ -109,20 +109,31 @@ case {'depth', 'zdepth'} info = exrinfo(inputFile); - % disp(info); - % fieldnames(info) - channelNames = info.channels; - if any(strcmp('P.X', channelNames)) - % Modern naming for X,Y,Z coordinates - % coordinates = exrread(inputFile,Channels=["P.X","P.Y","P.Z"]); - coordinates = exrread(inputFile); - elseif any(strcmp('Px', channelNames)) - % Historical naming - % coordinates = exrread(inputFile,Channels=["Px","Py","Pz"]); - coordinates = exrread(inputFile); - else - warning('No X,Y,Z channels found. Returning.'); - return; + + if isOctave() + channelNames = info.channels; + if any(strcmp('P.X', channelNames)) + % Modern naming for X,Y,Z coordinates + coordinates = exrread(inputFile); + elseif any(strcmp('Px', channelNames)) + % Historical naming + coordinates = exrread(inputFile); + else + warning('No X,Y,Z channels found. Returning.'); + return; + end + else % Matlab + channelNames = info.ChannelInfo.Properties.RowNames; + if contains('P.X',channelNames) + % Modern naming for X,Y,Z coordinates + coordinates = exrread(inputFile,Channels=["P.X","P.Y","P.Z"]); + elseif contains('Px',channelNames) + % Historical naming + coordinates = exrread(inputFile,Channels=["Px","Py","Pz"]); + else + warning('No X,Y,Z channels found. Returning.'); + return; + end end if isequal(label{ii},'depth') diff --git a/utilities/pbrt/pbrt-v4/piEXR2Mat.m b/utilities/pbrt/pbrt-v4/piEXR2Mat.m index 25b5894..fbcc795 100644 --- a/utilities/pbrt/pbrt-v4/piEXR2Mat.m +++ b/utilities/pbrt/pbrt-v4/piEXR2Mat.m @@ -18,15 +18,10 @@ % dockerWrapper Support, D. Cardinal, 2022 % -% Below lines are added for Octave compatiblity -% Should ideally support runs from both Octave and MATLAB - -% Determine if we're in Octave -isOctave = exist('OCTAVE_VERSION', 'builtin') ~= 0; - % Check if MATLAB exrread() is available +% This function is available only in Matlab >= R2022b hasBuiltinExrread = false; -if ~isOctave && exist('isMATLABReleaseOlderThan', 'file') > 0 +if ~isOctave() && exist('isMATLABReleaseOlderThan', 'file') > 0 hasBuiltinExrread = ~isMATLABReleaseOlderThan('R2022b'); end