yoonsejong / mh_huevent2014

GNU General Public License v2.0
2 stars 1 forks source link

distfcm function and colorcalc.mex #1

Open WenXinDong2018 opened 3 years ago

WenXinDong2018 commented 3 years ago

Hi,

After downloading all the necessary files, I ran into some errors.

1.Is there a step missing in the readme where one is excepted to download the distfcm function from this link?

  1. I'm not seeing where colorcalc.mex is used in the code base, and I had troubles generating the mex file.
  2. Assuming Yes to the first question and omitting the colorcalc.mex* file, without which the code can still ran, I ran collect_MH_features.m on some random image, and ran into the following error:
Index in position 1 is invalid. Array indices must be positive integers or logical
values.

Error in itten (line 89)
        xy = [xy(end,:); xy; xy(1,:)];

Error in collect_MH_Features (line 144)
[fullfeatures(22:41), fullfeatures(98)] = itten(img);

To temporarily bypass this error, I replaced feature 6 and feature 16 in the Itten file with 0, and here is a feature vector I got for a random image. As can be seen, feature #28 and #38 are 0s (corresponding to Itten feature #6 and #16).

0.222700081299947
0.718211096870800
0.544559674726840
-0.0890253912499798
0.617104459637791
0.530720948102808
0.960960938176237
-0.104241655748984
0.939209460786395
60.8022981261836
0.0395904961388000
0.350459764083375
0.0344600633341871
0.0537428277679468
0.0363860311588302
0.0370301977439113
0.0754686947888207
0.138995025930227
0.0437309355431238
0.154810592449058
0.0353253710617197
0.150057400580607
0.151313467836416
0.0452853736462183
-26.0821144430514
1
0
0
949.759164550661
NaN
NaN
0.150057400580607
0.151313467836416
1.99998462944387
3.12465553658501
1
0
0
17193.0690275822
0
0
0.000865069306133945
0.000241414690083892
0.000160943126722594
0.000422475707646810
0.00237391111915827
0.00191119962983081
0.00388275293218259
0.00331945198865351
0
0
0.000100589454201622
0.000181061017562919
0.00456676122075362
0.00460699700243426
0.00374192769630032
0.00171002072142757
0.000345729989059788
9.34445312749523e-07
3.57100412435505
0.00710161546663448
0.0279236324863701
0.251393163940692
0.270525278129841
0.443056309976462
0.00728267648419740
0.00589454201621502
0.114685789116378
0.00266540212844503
0.277564147124758
0.918507854428645
0.355986625204815
1
0.105633981663518
0.000433019566146501
-3.08162637729203e-05
0.610433538510885
0.000927437428985417
0.00258242559756492
-0.135976513751465
0.000278325046126904
-0.000147918503924695
0.106036184965892
0.613943401537435
-0.135846107209263
0.212765957446809
0.117001051694847
0.332618720168271
0.392571061002011
0.979433635207481
0.943362464563498
0.988114290746447
0.251786206766153
0.175454114227190
0.996084796267832
0.944277027209234
0.910080764770919
35
3.21227828412621
-0.901779026217229
9.38510167745250
-20.5714285714286
0.385714285714286
21.9186196887142
-44
0.255555555555556
41.5148542550203
2036.31890229414
1.52629233511586
7.06526087344029
0
0
0.0454463154082926
1

I would greatly appreciate your help.

yoonsejong commented 3 years ago

Hi,

1.Is there a step missing in the readme where one is excepted to download the distfcm function from this link?

No. It's mentioned in Step 7. To calculate the Wang's fuzzy C-Mean distance, you need to first find centroids from training data. My codebase has train/predict code to train the centroid. The distfcm function you mentioned merely calculates the distance after you have centroid calculated.

  1. I'm not seeing where colorcalc.mex is used in the code base, and I had troubles generating the mex file.

It can be downloaded (and compiled) from https://www.mathworks.com/matlabcentral/fileexchange/28790-colorspace-transformations as I explained in Step 4. I just downloaded and compiled again on my computer (Windows), and it correctly creates the needed mex file. It's just an x64 version. [image: image.png]

  1. Assuming Yes to the first question and omitting the colorcalc.mex* file, without which the code can still ran, I ran collect_MH_features.m on some random image, and ran into the following error:

It is possible that some feature values end up being zero. Regarding the initial error about index, I suggest you try square images instead of rectangular ones (not required, but often solves minor technical issues).

Thanks.

On Wed, Jun 30, 2021 at 1:36 AM WenXinDong2018 @.***> wrote:

Hi,

After downloading all the necessary files, I ran into some errors.

1.Is there a step missing in the readme where one is excepted to download the distfcm function from this link https://www.mathworks.com/matlabcentral/mlc-downloads/downloads/submissions/48686/versions/1/previews/FuzzyClusterToolBox/FCM_Matlab/distfcm.m/index.html ?

  1. I'm not seeing where colorcalc.mex is used in the code base, and I had troubles generating the mex file.
  2. Assuming Yes to the first question and omitting the colorcalc.mex* file, without which the code can still ran, I ran collect_MH_features.m on some random image, and ran into the following error:

Index in position 1 is invalid. Array indices must be positive integers or logical values.

Error in itten (line 89) xy = [xy(end,:); xy; xy(1,:)];

Error in collect_MH_Features (line 144) [fullfeatures(22:41), fullfeatures(98)] = itten(img);

To temporarily bypass this error, I replaced feature 6 and feature 16 in the Itten file with 0, and here is a feature vector I got for a random image. As can be seen, feature #28 and #38 are 0s (corresponding to Itten feature #6 and #16).

0.222700081299947 0.718211096870800 0.544559674726840 -0.0890253912499798 0.617104459637791 0.530720948102808 0.960960938176237 -0.104241655748984 0.939209460786395 60.8022981261836 0.0395904961388000 0.350459764083375 0.0344600633341871 0.0537428277679468 0.0363860311588302 0.0370301977439113 0.0754686947888207 0.138995025930227 0.0437309355431238 0.154810592449058 0.0353253710617197 0.150057400580607 0.151313467836416 0.0452853736462183 -26.0821144430514 1 0 0 949.759164550661 NaN NaN 0.150057400580607 0.151313467836416 1.99998462944387 3.12465553658501 1 0 0 17193.0690275822 0 0 0.000865069306133945 0.000241414690083892 0.000160943126722594 0.000422475707646810 0.00237391111915827 0.00191119962983081 0.00388275293218259 0.00331945198865351 0 0 0.000100589454201622 0.000181061017562919 0.00456676122075362 0.00460699700243426 0.00374192769630032 0.00171002072142757 0.000345729989059788 9.34445312749523e-07 3.57100412435505 0.00710161546663448 0.0279236324863701 0.251393163940692 0.270525278129841 0.443056309976462 0.00728267648419740 0.00589454201621502 0.114685789116378 0.00266540212844503 0.277564147124758 0.918507854428645 0.355986625204815 1 0.105633981663518 0.000433019566146501 -3.08162637729203e-05 0.610433538510885 0.000927437428985417 0.00258242559756492 -0.135976513751465 0.000278325046126904 -0.000147918503924695 0.106036184965892 0.613943401537435 -0.135846107209263 0.212765957446809 0.117001051694847 0.332618720168271 0.392571061002011 0.979433635207481 0.943362464563498 0.988114290746447 0.251786206766153 0.175454114227190 0.996084796267832 0.944277027209234 0.910080764770919 35 3.21227828412621 -0.901779026217229 9.38510167745250 -20.5714285714286 0.385714285714286 21.9186196887142 -44 0.255555555555556 41.5148542550203 2036.31890229414 1.52629233511586 7.06526087344029 0 0 0.0454463154082926 1

I would greatly appreciate your help.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/yoonsejong/mh_huevent2014/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEGOUX5LO5PF6RBMJXDQL4DTVKUOXANCNFSM47RSTLBQ .

WenXinDong2018 commented 3 years ago

Thank you so much for the help!

  1. If I understand correctly, I do not need to download the distfcm function from that link. However, where do I can find the definition of this function? Please correct me if I'm understanding incorrectly.

  2. I am getting the following error when I run mex colorcalc.cafter downloading the files. I am using macOS.

Error using mex Undefined symbols for architecture x86_64: "_Rgb2Cat02lms", referenced from: _main in colorcalc.o "_Rgb2Hsi", referenced from: _main in colorcalc.o "_Rgb2Hsl", referenced from: _main in colorcalc.o "_Rgb2Hsv", referenced from: _main in colorcalc.o "_Rgb2Jpegycbcr", referenced from: _main in colorcalc.o "_Rgb2Lab", referenced from: _main in colorcalc.o "_Rgb2Lch", referenced from: _main in colorcalc.o "_Rgb2Luv", referenced from: _main in colorcalc.o "_Rgb2Xyz", referenced from: _main in colorcalc.o "_Rgb2Ycbcr", referenced from: _main in colorcalc.o "_Rgb2Ydbdr", referenced from: _main in colorcalc.o "_Rgb2Yiq", referenced from: _main in colorcalc.o "_Rgb2Ypbpr", referenced from: _main in colorcalc.o "_Rgb2Yuv", referenced from: _main in colorcalc.o "_mexFunction", referenced from: -exported_symbol[s_list] command line option ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)


3. I tried with a square image(189*189) but the problem persisted. Upon closer inspection,  hueCounts are all 0s, which caused causes the shape of xy to be (0, 2). It seems like the bins for calculating the histogram counts are not on the same scale as the elements being binned: 

Here is your code:

binEdges = deg2rad([0:30:360] + 15); % bracket is necessary! hueCount = histc(segAvg(:,1) + deg2rad(15), binEdges); nHueCount = hueCount ./ sum(hueCount);

Here are the intermediate values:

binEdges:

Columns 1 through 8

0.2618    0.7854    1.3090    1.8326    2.3562    2.8798    3.4034    3.9270

Columns 9 through 13

4.4506    4.9742    5.4978    6.0214    6.5450

segAvg(:,1) + deg2rad(15):

222.9731 247.0450 212.0703 204.0663 197.0042 197.6083 201.8071 194.1002 189.9126 209.2357 230.8654 203.1387 194.6304 219.3623 234.8632 227.6115 240.2537 186.1529 196.3687 267.0756 206.5939 242.5771

yoonsejong commented 3 years ago
  1. No need. The fuzzyc wang matlab file in my repo does it. If you precalculate centroid, then you can use that distfcm function instead of mine.

  2. It seems the color code in mathworks has updated. Colorcalc.c is not mex source. You can just use colorspace.mex64.

2021년 6월 30일 (수) 오전 8:24, WenXinDong2018 @.***>님이 작성:

Thank you so much for the help!

1.

If I understand correctly, I do not need to download the distfcm function from that link. However, where do I can find the definition of this function? Please correct me if I'm understanding incorrectly. 2.

I am getting the following error when I run mex colorcalc.c after downloading the files. I am using macOS.

Error using mex Undefined symbols for architecture x86_64: "_Rgb2Cat02lms", referenced from: _main in colorcalc.o "_Rgb2Hsi", referenced from: _main in colorcalc.o "_Rgb2Hsl", referenced from: _main in colorcalc.o "_Rgb2Hsv", referenced from: _main in colorcalc.o "_Rgb2Jpegycbcr", referenced from: _main in colorcalc.o "_Rgb2Lab", referenced from: _main in colorcalc.o "_Rgb2Lch", referenced from: _main in colorcalc.o "_Rgb2Luv", referenced from: _main in colorcalc.o "_Rgb2Xyz", referenced from: _main in colorcalc.o "_Rgb2Ycbcr", referenced from: _main in colorcalc.o "_Rgb2Ydbdr", referenced from: _main in colorcalc.o "_Rgb2Yiq", referenced from: _main in colorcalc.o "_Rgb2Ypbpr", referenced from: _main in colorcalc.o "_Rgb2Yuv", referenced from: _main in colorcalc.o "_mexFunction", referenced from: -exported_symbol[s_list] command line option ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

  1. I tried with a square image(189*189) but the problem persisted. Upon closer inspection, hueCounts are all 0s, which caused causes the shape of xy to be (0, 2). It seems like the bins for calculating the histogram counts are not on the same scale as the elements being binned:

Here is your code:

binEdges = deg2rad([0:30:360] + 15); % bracket is necessary! hueCount = histc(segAvg(:,1) + deg2rad(15), binEdges); nHueCount = hueCount ./ sum(hueCount);

Here are the intermediate values:

binEdges:

Columns 1 through 8

0.2618    0.7854    1.3090    1.8326    2.3562    2.8798    3.4034    3.9270

Columns 9 through 13

4.4506    4.9742    5.4978    6.0214    6.5450

segAvg(:,1) + deg2rad(15):

222.9731 247.0450 212.0703 204.0663 197.0042 197.6083 201.8071 194.1002 189.9126 209.2357 230.8654 203.1387 194.6304 219.3623 234.8632 227.6115 240.2537 186.1529 196.3687 267.0756 206.5939 242.5771

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/yoonsejong/mh_huevent2014/issues/1#issuecomment-871357224, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEGOUX5OCHGU7D4BMVNEISLTVMEH3ANCNFSM47RSTLBQ .

WenXinDong2018 commented 3 years ago

Thank you, I will look into 1.

For 2. I generated colorspace.mex64, I renamed it colorcalc.mex64 and added it to the repository. Is this the right approach?

For the bug described in 3, do you have any idea for the cause? I added colorcalc.mex64 and the error persisted. Might it have something to do with 1.?

I sincerely appreciate your help!