Learning to Count Objects in Images

来源:互联网 发布:易众联读卡器软件 编辑:程序博客网 时间:2024/05/21 08:56

512x512

LEARNING TO COUNT CELLS IN MICROSCOPY IMAGES
----------
Loading pre-trained SIFT codebook...
----------
Loading features precomputed at previous run
Mexifying MaxSubarray procedure
Now using the first 16 images to train the model.
Now evaluating on the remaining 16 images
Image #17: trueCount = 1037.289089, model1 predicted count = 982.600081, model2 predicted count = 1057.813135...
Image #18: trueCount = 902.321797, model1 predicted count = 899.474861, model2 predicted count = 941.743415...
Image #19: trueCount = 916.903027, model1 predicted count = 903.791403, model2 predicted count = 919.675134...
Image #20: trueCount = 839.272395, model1 predicted count = 813.136032, model2 predicted count = 818.105666...
Image #21: trueCount = 733.254047, model1 predicted count = 712.500091, model2 predicted count = 748.239443...
Image #22: trueCount = 912.114909, model1 predicted count = 890.952815, model2 predicted count = 985.126443...
Image #23: trueCount = 785.644680, model1 predicted count = 764.083209, model2 predicted count = 810.097562...
Image #24: trueCount = 1120.874717, model1 predicted count = 1062.510115, model2 predicted count = 1035.219639...
Image #25: trueCount = 1461.897054, model1 predicted count = 1364.478048, model2 predicted count = 1351.713340...
Image #26: trueCount = 518.926329, model1 predicted count = 557.591903, model2 predicted count = 589.312230...
Image #27: trueCount = 905.214063, model1 predicted count = 860.339848, model2 predicted count = 869.919290...
Image #28: trueCount = 523.379045, model1 predicted count = 533.831107, model2 predicted count = 547.935585...
Image #29: trueCount = 1191.485937, model1 predicted count = 1181.006147, model2 predicted count = 1212.037304...
Image #30: trueCount = 457.913811, model1 predicted count = 556.901723, model2 predicted count = 579.454832...
Image #31: trueCount = 876.737472, model1 predicted count = 827.225498, model2 predicted count = 851.042363...
Image #32: trueCount = 910.812718, model1 predicted count = 843.014845, model2 predicted count = 851.909709...
--------------
Model 1 (L1) average error = 39.800904,
Model 2 (Tikhonov) average error = 46.818802

256x256

CellCountingExample
LEARNING TO COUNT CELLS IN MICROSCOPY IMAGES
----------
Loading pre-trained SIFT codebook...
----------
Loading features precomputed at previous run
Mexifying MaxSubarray procedure
Now using the first 16 images to train the model.
Now evaluating on the remaining 16 images
Image #17: trueCount = 213.092770, model1 predicted count = 202.693091, model2 predicted count = 202.500483...
Image #18: trueCount = 184.486352, model1 predicted count = 184.553051, model2 predicted count = 181.652222...
Image #19: trueCount = 188.030488, model1 predicted count = 192.124348, model2 predicted count = 188.130861...
Image #20: trueCount = 168.582203, model1 predicted count = 173.921780, model2 predicted count = 172.080294...
Image #21: trueCount = 149.547202, model1 predicted count = 148.533786, model2 predicted count = 145.389421...
Image #22: trueCount = 184.015927, model1 predicted count = 182.740380, model2 predicted count = 179.679187...
Image #23: trueCount = 160.521873, model1 predicted count = 158.214548, model2 predicted count = 157.520349...
Image #24: trueCount = 226.832367, model1 predicted count = 226.282014, model2 predicted count = 218.954249...
Image #25: trueCount = 297.921523, model1 predicted count = 286.771492, model2 predicted count = 270.575390...
Image #26: trueCount = 104.895969, model1 predicted count = 105.426018, model2 predicted count = 106.859841...
Image #27: trueCount = 184.283937, model1 predicted count = 184.071551, model2 predicted count = 181.512213...
Image #28: trueCount = 107.108313, model1 predicted count = 109.119808, model2 predicted count = 109.715871...
Image #29: trueCount = 242.999969, model1 predicted count = 249.026848, model2 predicted count = 233.373087...
Image #30: trueCount = 93.612752, model1 predicted count = 97.570344, model2 predicted count = 96.222404...
Image #31: trueCount = 179.325453, model1 predicted count = 178.352288, model2 predicted count = 173.511539...
Image #32: trueCount = 185.410291, model1 predicted count = 177.602848, model2 predicted count = 174.626900...
--------------
Model 1 (L1) average error = 3.607218,
Model 2 (Tikhonov) average error = 6.245136


Dict:128x256(特征数X类个数)

[f d] = vl_dsift(single(im));%抽取特征,f存放每个像素坐标,d存放每个像素特征,一列为一个记录。

features{j} = vl_ikmeanspush(uint8(d),Dict);%聚类,128维特征-->1维:1~256,聚类中心用字典。

estDensity1 = wL1(testFeatures{j}).*testWeights{j};%每个类赋予一个权重,类似特征选择.


MATLAB函数记录:

imshow(dd, [])%自动拉伸

fspecial('gaussian', 4.0*6, 4.0)%4.0*6 模板大小 4.0:标准差


project:http://www.vlfeat.org/download/vlfeat-0.9.20-bin.tar.gz

papaer:http://www.robots.ox.ac.uk/~vgg/research/counting/index.html


256x256 car 3x3dot

 CellCountingExample
LEARNING TO COUNT CELLS IN MICROSCOPY IMAGES
----------
Loading pre-trained SIFT codebook...
----------
Processing image #1 (out of total)...
Computing dense SIFT...
Quantizing SIFTs...
----------
Mexifying MaxSubarray procedure
Now using the first 16 images to train the model.
--------------
Training the model with L1 regularization:
--------------
L1 regularization is used.
Non-negative feature encoding assumed. w is constrained to be non-negative.
Starting iteration 1
Optimization terminated.
Convex program (re)solved. Generating constraints...
Statistics for image 1: True count: 192.4; Estimated count: 126.4; MESA-distance: 95.9; Previous slack: 0.0
Showing the GT density, the estimated density, the diff and the most violated constraint
Starting iteration 2
Optimization terminated.
Convex program (re)solved. Generating constraints...
Statistics for image 1: True count: 192.4; Estimated count: 155.7; MESA-distance: 93.8; Previous slack: 92.8
Showing the GT density, the estimated density, the diff and the most violated constraint
Starting iteration 3
Optimization terminated.
Convex program (re)solved. Generating constraints...
Starting iteration 4
Optimization terminated.
Convex program (re)solved. Generating constraints...
Starting iteration 5
Optimization terminated.
Convex program (re)solved. Generating constraints...
Constraint generation successfully converged
--------------
Training the model with Tikhonov regularization:
--------------
Tikhonov regularization is used.
Non-negative feature encoding assumed. w is constrained to be non-negative.
Starting iteration 1
Optimization terminated.
Convex program (re)solved. Generating constraints...
Statistics for image 1: True count: 192.4; Estimated count: 87.3; MESA-distance: 135.6; Previous slack: 28.3
Showing the GT density, the estimated density, the diff and the most violated constraint
Starting iteration 2
Optimization terminated.
Convex program (re)solved. Generating constraints...
Statistics for image 1: True count: 192.4; Estimated count: 227.9; MESA-distance: 76.5; Previous slack: 20.3
Showing the GT density, the estimated density, the diff and the most violated constraint
Starting iteration 3
Optimization terminated.
Convex program (re)solved. Generating constraints...
Statistics for image 1: True count: 192.4; Estimated count: 136.3; MESA-distance: 88.6; Previous slack: 85.9
Showing the GT density, the estimated density, the diff and the most violated constraint
Starting iteration 4
Optimization terminated.
Convex program (re)solved. Generating constraints...
Statistics for image 1: True count: 192.4; Estimated count: 137.8; MESA-distance: 93.9; Previous slack: 92.0
Showing the GT density, the estimated density, the diff and the most violated constraint
Starting iteration 5
Optimization terminated.
Convex program (re)solved. Generating constraints...
Constraint generation successfully converged
Now evaluating on the remaining 16 images
Image #18: trueCount = 131.606462, model1 predicted count = 124.900195, model2 predicted count = 125.115966...
Image #19: trueCount = 119.934360, model1 predicted count = 124.631853, model2 predicted count = 124.928064...
Image #20: trueCount = 35.002689, model1 predicted count = 144.803268, model2 predicted count = 144.568718...
Image #21: trueCount = 0.000000, model1 predicted count = 139.168053, model2 predicted count = 138.937993...
Image #22: trueCount = 71.382232, model1 predicted count = 147.680527, model2 predicted count = 147.505314...
Image #23: trueCount = 136.822125, model1 predicted count = 135.155380, model2 predicted count = 134.994246...
Image #24: trueCount = 90.947890, model1 predicted count = 190.190667, model2 predicted count = 189.787236...
Image #25: trueCount = 109.142492, model1 predicted count = 122.660761, model2 predicted count = 122.925231...
Image #26: trueCount = 252.784567, model1 predicted count = 142.592612, model2 predicted count = 143.087110...
Image #27: trueCount = 97.535851, model1 predicted count = 156.261816, model2 predicted count = 155.960496...
Image #28: trueCount = 103.140029, model1 predicted count = 174.573521, model2 predicted count = 174.267322...
Image #29: trueCount = 7.832870, model1 predicted count = 160.098179, model2 predicted count = 159.804592...
Image #30: trueCount = 37.144857, model1 predicted count = 132.439796, model2 predicted count = 132.267627...
Image #31: trueCount = 16.969688, model1 predicted count = 135.163770, model2 predicted count = 134.980179...
Image #32: trueCount = 168.199009, model1 predicted count = 147.919089, model2 predicted count = 147.672183...
Image #33: trueCount = 104.985626, model1 predicted count = 174.447340, model2 predicted count = 174.156899...
Image #34: trueCount = 107.678497, model1 predicted count = 195.315367, model2 predicted count = 195.040363...
--------------
Model 1 (L1) average error = 72.622513,
Model 2 (Tikhonov) average error = 72.469154

256x256 car 1x1dot only road

CellCountingExample
LEARNING TO COUNT CELLS IN MICROSCOPY IMAGES
----------
Loading pre-trained SIFT codebook...
Convex program (re)solved. Generating constraints...
Constraint generation successfully converged
Now evaluating on the remaining 16 images
Image #18: trueCount = 14.626592, model1 predicted count = 8.627431, model2 predicted count = 7.288281...
Image #19: trueCount = 13.328222, model1 predicted count = 11.117148, model2 predicted count = 10.048189...
Image #20: trueCount = 3.896392, model1 predicted count = 7.556465, model2 predicted count = 6.310726...
Image #21: trueCount = 0.000000, model1 predicted count = 8.943107, model2 predicted count = 7.019147...
Image #22: trueCount = 7.885236, model1 predicted count = 25.873177, model2 predicted count = 26.618888...
Image #23: trueCount = 15.203559, model1 predicted count = 14.346122, model2 predicted count = 12.050922...
Image #24: trueCount = 10.106621, model1 predicted count = 13.971964, model2 predicted count = 11.919469...
Image #25: trueCount = 12.157121, model1 predicted count = 7.546810, model2 predicted count = 5.733517...
Image #26: trueCount = 28.070755, model1 predicted count = 15.693807, model2 predicted count = 15.797125...
Image #27: trueCount = 10.842879, model1 predicted count = 19.714074, model2 predicted count = 17.858557...
Image #28: trueCount = 11.450628, model1 predicted count = 22.941584, model2 predicted count = 22.294760...
Image #29: trueCount = 0.876985, model1 predicted count = 5.114584, model2 predicted count = 3.658621...
Image #30: trueCount = 4.156869, model1 predicted count = 15.040042, model2 predicted count = 15.777736...
Image #31: trueCount = 1.891195, model1 predicted count = 5.511325, model2 predicted count = 4.451032...
Image #32: trueCount = 18.692430, model1 predicted count = 15.602146, model2 predicted count = 13.288622...
Image #33: trueCount = 11.667414, model1 predicted count = 15.721074, model2 predicted count = 14.619873...
Image #34: trueCount = 11.968039, model1 predicted count = 15.883169, model2 predicted count = 16.667407...
--------------
Model 1 (L1) average error = 6.510207,
Model 2 (Tikhonov) average error = 6.489764


256x256 car 1x1dot only road random dictionary
L1 regularization is used.
Non-negative feature encoding assumed. w is constrained to be non-negative.
Starting iteration 1
Optimization terminated.
Convex program (re)solved. Generating constraints...
Constraint generation successfully converged
Now evaluating on the remaining 16 images
Image #18: trueCount = 14.626592, model1 predicted count = 6.343956, model2 predicted count = 7.221655...
Image #19: trueCount = 13.328222, model1 predicted count = 9.892732, model2 predicted count = 11.477049...
Image #20: trueCount = 3.896392, model1 predicted count = 6.186591, model2 predicted count = 6.308676...
Image #21: trueCount = 0.000000, model1 predicted count = 10.779834, model2 predicted count = 10.335965...
Image #22: trueCount = 7.885236, model1 predicted count = 24.825413, model2 predicted count = 25.109806...
Image #23: trueCount = 15.203559, model1 predicted count = 17.523468, model2 predicted count = 16.569190...
Image #24: trueCount = 10.106621, model1 predicted count = 13.201538, model2 predicted count = 13.070310...
Image #25: trueCount = 12.157121, model1 predicted count = 6.829115, model2 predicted count = 6.677826...
Image #26: trueCount = 28.070755, model1 predicted count = 20.473060, model2 predicted count = 20.807300...
Image #27: trueCount = 10.842879, model1 predicted count = 20.670932, model2 predicted count = 20.521331...
Image #28: trueCount = 11.450628, model1 predicted count = 23.534275, model2 predicted count = 24.415945...
Image #29: trueCount = 0.876985, model1 predicted count = 3.440044, model2 predicted count = 3.476942...
Image #30: trueCount = 4.156869, model1 predicted count = 13.297606, model2 predicted count = 13.734694...
Image #31: trueCount = 1.891195, model1 predicted count = 3.037231, model2 predicted count = 3.220964...
Image #32: trueCount = 18.692430, model1 predicted count = 16.297853, model2 predicted count = 16.117108...
Image #33: trueCount = 11.667414, model1 predicted count = 16.624075, model2 predicted count = 17.015325...
Image #34: trueCount = 11.968039, model1 predicted count = 13.276083, model2 predicted count = 13.695724...
--------------
Model 1 (L1) average error = 6.087628,
Model 2 (Tikhonov) average error = 6.006073

256x256 car 1x1dot only road  100 class dictionary

Now evaluating on the remaining 16 images
Image #18: trueCount = 14.626592, model1 predicted count = 6.083973, model2 predicted count = 7.396912...
Image #19: trueCount = 13.328222, model1 predicted count = 9.826230, model2 predicted count = 10.169291...
Image #20: trueCount = 3.896392, model1 predicted count = 5.737594, model2 predicted count = 5.975983...
Image #21: trueCount = 0.000000, model1 predicted count = 8.660866, model2 predicted count = 8.145593...
Image #22: trueCount = 7.885236, model1 predicted count = 27.377197, model2 predicted count = 28.175510...
Image #23: trueCount = 15.203559, model1 predicted count = 14.122257, model2 predicted count = 15.902352...
Image #24: trueCount = 10.106621, model1 predicted count = 11.904425, model2 predicted count = 12.996976...
Image #25: trueCount = 12.157121, model1 predicted count = 3.783629, model2 predicted count = 5.137370...
Image #26: trueCount = 28.070755, model1 predicted count = 16.053417, model2 predicted count = 16.683966...
Image #27: trueCount = 10.842879, model1 predicted count = 19.224462, model2 predicted count = 18.204273...
Image #28: trueCount = 11.450628, model1 predicted count = 21.069659, model2 predicted count = 20.464855...
Image #29: trueCount = 0.876985, model1 predicted count = 2.906741, model2 predicted count = 3.019275...
Image #30: trueCount = 4.156869, model1 predicted count = 14.865498, model2 predicted count = 13.596614...
Image #31: trueCount = 1.891195, model1 predicted count = 2.902232, model2 predicted count = 3.017645...
Image #32: trueCount = 18.692430, model1 predicted count = 15.870265, model2 predicted count = 17.485046...
Image #33: trueCount = 11.667414, model1 predicted count = 17.340189, model2 predicted count = 17.913747...
Image #34: trueCount = 11.968039, model1 predicted count = 15.503634, model2 predicted count = 15.183435...
--------------
Model 1 (L1) average error = 6.417009,
Model 2 (Tikhonov) average error = 6.038410


256x256 car 1x1dot only road  100 class dictionary of only road

--------------- Loading wL1_wL2.mat
Now evaluating on the remaining 16 images
Image #18: trueCount =   14.627, model1 count =   10.583, model2 count =   11.075 error =   -4.043
Image #19: trueCount =   13.328, model1 count =   13.849, model2 count =   14.427 error =    0.521
Image #20: trueCount =    3.896, model1 count =    5.007, model2 count =    5.216 error =    1.111
Image #21: trueCount =    0.000, model1 count =    7.154, model2 count =    7.478 error =    7.154
Image #22: trueCount =    7.885, model1 count =   27.565, model2 count =   30.966 error =   19.679
Image #23: trueCount =   15.204, model1 count =   14.976, model2 count =   13.310 error =   -1.894
Image #24: trueCount =   10.107, model1 count =   13.915, model2 count =   12.544 error =    2.438
Image #25: trueCount =   12.157, model1 count =   13.399, model2 count =   13.235 error =    1.078
Image #26: trueCount =   28.071, model1 count =   29.544, model2 count =   30.161 error =    1.474
Image #27: trueCount =   10.843, model1 count =   20.456, model2 count =   18.777 error =    7.934
Image #28: trueCount =   11.451, model1 count =   26.983, model2 count =   23.622 error =   12.171
Image #29: trueCount =    0.877, model1 count =    2.209, model2 count =    2.700 error =    1.332
Image #30: trueCount =    4.157, model1 count =   12.994, model2 count =   14.494 error =    8.837
Image #31: trueCount =    1.891, model1 count =    2.231, model2 count =    2.753 error =    0.340
Image #32: trueCount =   18.692, model1 count =   17.155, model2 count =   15.336 error =   -3.356
Image #33: trueCount =   11.667, model1 count =   17.145, model2 count =   18.179 error =    5.477
Image #34: trueCount =   11.968, model1 count =   14.907, model2 count =   16.776 error =    2.939
--------------
Model 1 (L1) average error = 4.992256,
Model 2 (Tikhonov) average error = 5.401815


features{j} = vl_ikmeanspush(uint8(d),Dict);输入输出都要整型

[Dict, assignments] = vl_kmeans(data, numClusters);%生成的字典是双精度的(带小数点),所以直接用上面的额函数分类是否会造成误差.


原始应用sift特征效果不是很好,有时候维度小的时候学习出来的W基本没什么信息。

如果改用HOG又存在标记密度的困难,可以试试.

0 0