question about colorChecker and issue with makeOutline
Hi Steven,
I have been trying to use patternize to calibrate images (using colorChecker) and apply a mask on the image using maskOutline. I have two questions:
-
When using colorChecker on a set of images, is there a way to skip the stage when you have to press enter to save the calibrated image each time? I would like to run the script on a set of images without having to press enter multiple times.
-
When trying to apply a mask (which will define my ROI in the image to be analysed) I seem to have run into an issue. I have saved the coordinates of a polygon in ImageJ which defines the outlines of the mask I want to apply in the file 'XY_Coordinates1010s.txt'. But then when I try to run the code I get the
outline <- read.table('XY_Coordinates1010s.txt', header = FALSE)
ii <- makeList('1D3A1010s.jpg_calibrated', type='image') [1] "sample 1 1D3A1010s.jpg_calibrated added to list" >
img2 <- maskOutline(RasterStack=ii[[1]], outline=outline) Error: unable to find an inherited method for function ‘extent’ for signature ‘x = "NULL"’
I would be thankful for any suggestions.
Thanks in advance and thanks for the great package!
Kaspar
Dear Kasper,
If your colorChecker is in the same position in each picture, you can use 'fixedCorners = TRUE'
Could you send me the picture and outline? I could haev a quick look.
Best,
Steven
Van Belleghem Steven
Van: kaspardelhey @.> Verzonden: woensdag 13 augustus 2025 7:59 Aan: StevenVB12/patternize @.> CC: Subscribed @.***> Onderwerp: [StevenVB12/patternize] question about colorChecker and issue with makeOutline (Issue #46)
[https://avatars.githubusercontent.com/u/226236686?s=20&v=4]kaspardelhey created an issue (StevenVB12/patternize#46)https://github.com/StevenVB12/patternize/issues/46
Hi Steven,
I have been trying to use patternize to calibrate images (using colorChecker) and apply a mask on the image using maskOutline. I have two questions:
-
When using colorChecker on a set of images, is there a way to skip the stage when you have to press enter to save the calibrated image each time? I would like to run the script on a set of images without having to press enter multiple times.
-
When trying to apply a mask (which will define my ROI in the image to be analysed) I seem to have run into an issue. I have saved the coordinates of a polygon in ImageJ which defines the outlines of the mask I want to apply in the file 'XY_Coordinates1010s.txt'. But then when I try to run the code I get the
outline <- read.table('XY_Coordinates1010s.txt', header = FALSE)
ii <- makeList('1D3A1010s.jpg_calibrated', type='image') [1] "sample 1 1D3A1010s.jpg_calibrated added to list" >
img2 <- maskOutline(RasterStack=ii[[1]], outline=outline) Error: unable to find an inherited method for function ‘extent’ for signature ‘x = "NULL"’
I would be thankful for any suggestions.
Thanks in advance and thanks for the great package!
Kaspar
— Reply to this email directly, view it on GitHubhttps://github.com/StevenVB12/patternize/issues/46, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABQOC46AK6UXCLV3VJNCT6L3NLH2JAVCNFSM6AAAAACDYQZCDCVHI2DSMVQWIX3LMV43ASLTON2WKOZTGMYTOMBRGM3TQMA. You are receiving this because you are subscribed to this thread.Message ID: @.***>
Hi Steven, Thanks for the quick reply!
-
Unfortunately the chart is in different positions in different pictures, so I guess the only way to change that will be to see if the function can be changed to avoid the prompt, I will have a look.
-
I attach the dropbox link to a folder with the script, uncalibrated and calibrated images, xrite coordinates and polygon coordinates, because mail bounced due to its size. https://www.dropbox.com/scl/fo/ew5n64d0u495my7346uzk/AHozhm-DIAmB7H2GHFMaAKE?rlkey=3rsarh1kogcqomnfafgyzc63k&dl=0
Thanks for checking this out and let me know if you can't access the files
Cheers,
Kaspar
Hi Kasper,
You would only need to remove line 778-780 here https://github.com/StevenVB12/patternize/blob/master/R/colorChecker.R
if(all(c(fixedCorners == FALSE, is.null(fixedModel)))){ todo <- readline(prompt="Press [enter] to continue and save image >>> ") }
2. It took me some effort too as the code has seemed to be getting more buggy... Sorry! This works for me:
xy_coords <- makeList( IDlist=c('xrite_coords.txt'), type='landmark', prepath = NULL, extension = NULL, format = "imageJ", tpsFile = NULL, skipLandmark = NULL )
img <- colorChecker( IDlist=c('1D3A1010s'), prepath = NULL, extension = '.jpg', colorCheckerType = "X-Rite", fixedCorners = FALSE, patchSize = 0.6, colorCheckerXY = xy_coords, fixedModel = NULL, resampleFactor = NULL, adjustCoords = TRUE )
outline <- read.table('XY_Coordinates1010s.txt', header = FALSE)
#this step is not needed if we run the script from the start #img <- makeList('1D3A1010s.jpg_calibrated', type='image')
IDlist=c('1D3A1010s') prepath <- NULL extension <- '_calibrated.jpg' imageList <- makeList(IDlist, 'image', prepath, extension)
img2 <- maskOutline(imageList[[1]], outline, 'target', imageList = imageList, adjustCoords = TRUE, flipOutline = 'y')
raster::plot(img2)
Van Belleghem Steven
Van: kaspardelhey @.> Verzonden: woensdag 13 augustus 2025 12:02 Aan: StevenVB12/patternize @.> CC: Steven M. Van Belleghem @.>; Comment @.> Onderwerp: Re: [StevenVB12/patternize] question about colorChecker and issue with makeOutline (Issue #46)
[https://avatars.githubusercontent.com/u/226236686?s=20&v=4]kaspardelhey left a comment (StevenVB12/patternize#46)https://github.com/StevenVB12/patternize/issues/46#issuecomment-3183100301
Hi Steven, Thanks for the quick reply!
-
Unfortunately the chart is in different positions in different pictures, so I guess the only way to change that will be to see if the function can be changed to avoid the prompt, I will have a look.
-
I attach the dropbox link to a folder with the script, uncalibrated and calibrated images, xrite coordinates and polygon coordinates, because mail bounced due to its size. https://www.dropbox.com/scl/fo/ew5n64d0u495my7346uzk/AHozhm-DIAmB7H2GHFMaAKE?rlkey=3rsarh1kogcqomnfafgyzc63k&dl=0
Thanks for checking this out and let me know if you can't access the files
Cheers,
Kaspar
— Reply to this email directly, view it on GitHubhttps://github.com/StevenVB12/patternize/issues/46#issuecomment-3183100301, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABQOC434ZLPVPN7R3SREZ3D3NMEKFAVCNFSM6AAAAACDYQZCDCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTCOBTGEYDAMZQGE. You are receiving this because you commented.Message ID: @.***>
Hi Steven,
Thanks for the quick fix! It seems to work now. I will let you know how I go about it. The only further issue is that I wanted to continue with some functions from the package recolorize, but when I try to use function:
img3 <- brick_to_array(img2)
I get the following error message:
Error in .local(x, ...) : invalid layer names
Not sure what causes that, but I may contact Hannah Weller about it, since she is the first author of that package.
Cheers!
Kaspar
On Thu, Aug 14, 2025 at 2:33 AM Steven M. Van Belleghem < @.***> wrote:
StevenVB12 left a comment (StevenVB12/patternize#46) https://github.com/StevenVB12/patternize/issues/46#issuecomment-3184621700 Hi Kasper,
You would only need to remove line 778-780 here https://github.com/StevenVB12/patternize/blob/master/R/colorChecker.R
if(all(c(fixedCorners == FALSE, is.null(fixedModel)))){ todo <- readline(prompt="Press [enter] to continue and save image >>> ") }
- It took me some effort too as the code has seemed to be getting more buggy... Sorry! This works for me:
xy_coords <- makeList( IDlist=c('xrite_coords.txt'), type='landmark', prepath = NULL, extension = NULL, format = "imageJ", tpsFile = NULL, skipLandmark = NULL )
img <- colorChecker( IDlist=c('1D3A1010s'), prepath = NULL, extension = '.jpg', colorCheckerType = "X-Rite", fixedCorners = FALSE, patchSize = 0.6, colorCheckerXY = xy_coords, fixedModel = NULL, resampleFactor = NULL, adjustCoords = TRUE )
outline <- read.table('XY_Coordinates1010s.txt', header = FALSE)
#this step is not needed if we run the script from the start #img <- makeList('1D3A1010s.jpg_calibrated', type='image')
IDlist=c('1D3A1010s') prepath <- NULL extension <- '_calibrated.jpg' imageList <- makeList(IDlist, 'image', prepath, extension)
img2 <- maskOutline(imageList[[1]], outline, 'target', imageList = imageList, adjustCoords = TRUE, flipOutline = 'y')
raster::plot(img2)
Van Belleghem Steven
Van: kaspardelhey @.> Verzonden: woensdag 13 augustus 2025 12:02 Aan: StevenVB12/patternize @.> CC: Steven M. Van Belleghem @.>; Comment @.> Onderwerp: Re: [StevenVB12/patternize] question about colorChecker and issue with makeOutline (Issue #46)
[https://avatars.githubusercontent.com/u/226236686?s=20&v=4]kaspardelhey left a comment (StevenVB12/patternize#46)< https://github.com/StevenVB12/patternize/issues/46#issuecomment-3183100301>
Hi Steven, Thanks for the quick reply!
Unfortunately the chart is in different positions in different pictures, so I guess the only way to change that will be to see if the function can be changed to avoid the prompt, I will have a look.
I attach the dropbox link to a folder with the script, uncalibrated and calibrated images, xrite coordinates and polygon coordinates, because mail bounced due to its size.
https://www.dropbox.com/scl/fo/ew5n64d0u495my7346uzk/AHozhm-DIAmB7H2GHFMaAKE?rlkey=3rsarh1kogcqomnfafgyzc63k&dl=0
Thanks for checking this out and let me know if you can't access the files
Cheers,
Kaspar
— Reply to this email directly, view it on GitHub< https://github.com/StevenVB12/patternize/issues/46#issuecomment-3183100301>, or unsubscribe< https://github.com/notifications/unsubscribe-auth/ABQOC434ZLPVPN7R3SREZ3D3NMEKFAVCNFSM6AAAAACDYQZCDCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTCOBTGEYDAMZQGE>.
You are receiving this because you commented.Message ID: @.***>
— Reply to this email directly, view it on GitHub https://github.com/StevenVB12/patternize/issues/46#issuecomment-3184621700, or unsubscribe https://github.com/notifications/unsubscribe-auth/BV6BSDQG7JX4QPZAP2WRMUT3NNSFNAVCNFSM6AAAAACDYQZCDCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTCOBUGYZDCNZQGA . You are receiving this because you authored the thread.Message ID: @.***>
Hmm, I can't reproduce that error. The step seems to work for me...
Steven
Van Belleghem Steven
Van: kaspardelhey @.> Verzonden: donderdag 14 augustus 2025 3:24 Aan: StevenVB12/patternize @.> CC: Steven M. Van Belleghem @.>; Comment @.> Onderwerp: Re: [StevenVB12/patternize] question about colorChecker and issue with makeOutline (Issue #46)
[https://avatars.githubusercontent.com/u/226236686?s=20&v=4]kaspardelhey left a comment (StevenVB12/patternize#46)https://github.com/StevenVB12/patternize/issues/46#issuecomment-3186371330 Hi Steven,
Thanks for the quick fix! It seems to work now. I will let you know how I go about it. The only further issue is that I wanted to continue with some functions from the package recolorize, but when I try to use function:
img3 <- brick_to_array(img2)
I get the following error message:
Error in .local(x, ...) : invalid layer names
Not sure what causes that, but I may contact Hannah Weller about it, since she is the first author of that package.
Cheers!
Kaspar
On Thu, Aug 14, 2025 at 2:33 AM Steven M. Van Belleghem < @.***> wrote:
StevenVB12 left a comment (StevenVB12/patternize#46) https://github.com/StevenVB12/patternize/issues/46#issuecomment-3184621700 Hi Kasper,
You would only need to remove line 778-780 here https://github.com/StevenVB12/patternize/blob/master/R/colorChecker.R
if(all(c(fixedCorners == FALSE, is.null(fixedModel)))){ todo <- readline(prompt="Press [enter] to continue and save image >>> ") }
- It took me some effort too as the code has seemed to be getting more buggy... Sorry! This works for me:
xy_coords <- makeList( IDlist=c('xrite_coords.txt'), type='landmark', prepath = NULL, extension = NULL, format = "imageJ", tpsFile = NULL, skipLandmark = NULL )
img <- colorChecker( IDlist=c('1D3A1010s'), prepath = NULL, extension = '.jpg', colorCheckerType = "X-Rite", fixedCorners = FALSE, patchSize = 0.6, colorCheckerXY = xy_coords, fixedModel = NULL, resampleFactor = NULL, adjustCoords = TRUE )
outline <- read.table('XY_Coordinates1010s.txt', header = FALSE)
#this step is not needed if we run the script from the start #img <- makeList('1D3A1010s.jpg_calibrated', type='image')
IDlist=c('1D3A1010s') prepath <- NULL extension <- '_calibrated.jpg' imageList <- makeList(IDlist, 'image', prepath, extension)
img2 <- maskOutline(imageList[[1]], outline, 'target', imageList = imageList, adjustCoords = TRUE, flipOutline = 'y')
raster::plot(img2)
Van Belleghem Steven
Van: kaspardelhey @.> Verzonden: woensdag 13 augustus 2025 12:02 Aan: StevenVB12/patternize @.> CC: Steven M. Van Belleghem @.>; Comment @.> Onderwerp: Re: [StevenVB12/patternize] question about colorChecker and issue with makeOutline (Issue #46)
[https://avatars.githubusercontent.com/u/226236686?s=20&v=4]kaspardelhey left a comment (StevenVB12/patternize#46)< https://github.com/StevenVB12/patternize/issues/46#issuecomment-3183100301>
Hi Steven, Thanks for the quick reply!
Unfortunately the chart is in different positions in different pictures, so I guess the only way to change that will be to see if the function can be changed to avoid the prompt, I will have a look.
I attach the dropbox link to a folder with the script, uncalibrated and calibrated images, xrite coordinates and polygon coordinates, because mail bounced due to its size.
https://www.dropbox.com/scl/fo/ew5n64d0u495my7346uzk/AHozhm-DIAmB7H2GHFMaAKE?rlkey=3rsarh1kogcqomnfafgyzc63k&dl=0
Thanks for checking this out and let me know if you can't access the files
Cheers,
Kaspar
— Reply to this email directly, view it on GitHub< https://github.com/StevenVB12/patternize/issues/46#issuecomment-3183100301>, or unsubscribe< https://github.com/notifications/unsubscribe-auth/ABQOC434ZLPVPN7R3SREZ3D3NMEKFAVCNFSM6AAAAACDYQZCDCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTCOBTGEYDAMZQGE>.
You are receiving this because you commented.Message ID: @.***>
— Reply to this email directly, view it on GitHub https://github.com/StevenVB12/patternize/issues/46#issuecomment-3184621700, or unsubscribe https://github.com/notifications/unsubscribe-auth/BV6BSDQG7JX4QPZAP2WRMUT3NNSFNAVCNFSM6AAAAACDYQZCDCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTCOBUGYZDCNZQGA . You are receiving this because you authored the thread.Message ID: @.***>
— Reply to this email directly, view it on GitHubhttps://github.com/StevenVB12/patternize/issues/46#issuecomment-3186371330, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABQOC435MMLQGTO7BDYYUYL3NPQMZAVCNFSM6AAAAACDYQZCDCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTCOBWGM3TCMZTGA. You are receiving this because you commented.Message ID: @.***>