StevenVB12 / patternize

An R package for quantifying color pattern variation
31 stars 8 forks source link

Problems with singular matricies. #3

Closed humberto-ortiz closed 7 years ago

humberto-ortiz commented 7 years ago

Running on R 3.2.3 on Windows 10, or R version 3.3.3 on Ubuntu 16.04 gives errors on example code in the package documentation.

The help page for patLanRGB has the following sample code:

IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004')
prepath <- system.file("extdata",  package = 'patternize')
extension <- '_landmarks_LFW.txt'

landmarkList <- makeList(IDlist, 'landmark', prepath, extension)

extension <- '.JPG' ### Should be jpg on linux
imageList <- makeList(IDlist, 'image', prepath, extension)

RGB <- c(114,17,0)
rasterList_lanRGB <- patLanRGB(imageList, landmarkList, RGB, resampleFactor = 3,
                               colOffset = 0.15, crop = TRUE, res = 150, adjustCoords = TRUE, plot = TRUE)
` ` ` 
Running this code gives the following output
` ` `
[1] "sample 1 BC0077 added to array"
[1] "sample 2 BC0071 added to array"
[1] "sample 3 BC0050 added to array"
[1] "sample 4 BC0049 added to array"
[1] "sample 5 BC0004 added to array"
Error in as.matrix(base::solve(L, m2)) : 
  error in evaluating the argument 'x' in selecting a method for function 'as.matrix': Error in solve.default(L, m2) : 
  system is computationally singular: reciprocal condition number = 8.26195e-18

On linux, the error is slightly different.

Error in solve.default(L, m2) :
  system is computationally singular: reciprocal condition number = 8.26195e-18
StevenVB12 commented 7 years ago

Thanks Humberto, I think something has changed in the dependencies in the last 2 months. I updated Morpho and now I can reproduce the error in windows. My guess is that the problem is in an update of the package 'Matrix' that makes Morpho crash. Hope to solve it soon.

Cheers, Steven

humberto-ortiz commented 7 years ago

I think I found a workaround.

Here is the image resulting from the sample data provided with the package.

I was able to process the images by changing the call to solve(L, m2) in Morpho::computeTransform to call Matrix::solve(L, m2) instead.

Can you test the code? I don' t know if the result is what you expected. If it works we can propose the change to Morpho.

On 18 March 2017 at 13:44, Steven M. Van Belleghem <notifications@github.com

wrote:

Thanks Humberto, I think something has changed in the dependencies in the last 2 months. I updated Morpho and now I can reproduce the error in windows. My guess is that the problem is in an update of the package 'Matrix' that makes Morpho crash. Hope to solve it soon.

Cheers, Steven

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/StevenVB12/patternize/issues/3#issuecomment-287562163, or mute the thread https://github.com/notifications/unsubscribe-auth/ABTVXvLFHd9emLcxOZetipeDa_smGhvFks5rnBfqgaJpZM4Mhc45 .

-- Humberto Ortiz-Zuazaga

humberto-ortiz commented 7 years ago

Sorry, here's the plot.

rplot01

StevenVB12 commented 7 years ago

Wow. How did you change the code? I'm talking with the Morpho guy, but haven't found a solution yet.

humberto-ortiz commented 7 years ago

I just defined new functions my.computeTransform and my.patLanRGB with the changes I wanted.

The right way is to fork Morpho on github, make the change in your repo, and install it with install_github() from your copy.

Then you can send Stefan a pull request with the changes.

Did you see his comment about scaling the matrix? That might be a better solution. I worry the error is trying to tell you something important about the system.

On 18 March 2017 at 17:49, Steven M. Van Belleghem <notifications@github.com

wrote:

Wow. How did you change the code? I'm talking with the Morpho guy, but haven't found a solution yet.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/StevenVB12/patternize/issues/3#issuecomment-287577382, or mute the thread https://github.com/notifications/unsubscribe-auth/ABTVXhGfziUwF9nDM1LVGHot1U_Rz-2Qks5rnFF2gaJpZM4Mhc45 .

-- Humberto Ortiz-Zuazaga

StevenVB12 commented 7 years ago

I'm afraid that scaling the matrix would not allow to get the correct transformation I need to transform the images or color patterns..

-------- Original message -------- From: Humberto Ortiz-Zuazaga notifications@github.com Date: 18/03/2017 23:09 (GMT+01:00) To: StevenVB12/patternize patternize@noreply.github.com Cc: "Steven M. Van Belleghem" vanbelleghemsteven@hotmail.com, Comment comment@noreply.github.com Subject: Re: [StevenVB12/patternize] Problems with singular matricies. (#3)

I just defined new functions my.computeTransform and my.patLanRGB with the changes I wanted.

The right way is to fork Morpho on github, make the change in your repo, and install it with install_github() from your copy.

Then you can send Stefan a pull request with the changes.

Did you see his comment about scaling the matrix? That might be a better solution. I worry the error is trying to tell you something important about the system.

On 18 March 2017 at 17:49, Steven M. Van Belleghem <notifications@github.com

wrote:

Wow. How did you change the code? I'm talking with the Morpho guy, but haven't found a solution yet.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/StevenVB12/patternize/issues/3#issuecomment-287577382, or mute the thread https://github.com/notifications/unsubscribe-auth/ABTVXhGfziUwF9nDM1LVGHot1U_Rz-2Qks5rnFF2gaJpZM4Mhc45 .

-- Humberto Ortiz-Zuazaga

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/StevenVB12/patternize/issues/3#issuecomment-287578404, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AGDhc9UOYkrCdWDVSvLpFibsxFn317y6ks5rnFYIgaJpZM4Mhc45.

StevenVB12 commented 7 years ago

I added the following to the description, so it will call for the latest version of Morpho:

DevPackage: zarquon42b/Morpho

Let me know in case you would know a better way.

Steven