- Timestamp:
- 2015-05-20T23:25:37+12:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
other-projects/nz-flag-design/trunk/similarity-2d/flag-processing.js
r29806 r29906 251 251 } 252 252 253 console.log("Product for HSL histogram: " + quant_product);253 //console.log("Product for HSL histogram: " + quant_product); 254 254 255 255 return quant_product; … … 283 283 284 284 var imageObj = new Image(); 285 285 286 imageObj.onload = function() { 286 287 callback_count++; … … 333 334 if (clicked_on_count==2) { 334 335 // trigger comparison 335 alert("Similarity score: " + quantizedColourHistogramComparison(flag_comparison_array[0],flag_comparison_array[1]) );336 alert("Similarity score: " + quantizedColourHistogramComparison(flag_comparison_array[0],flag_comparison_array[1]) + "%"); 336 337 clicked_on_count=0; 337 338 } … … 346 347 347 348 348 imageObj.src = img_url; 349 imageObj.title = title.toUpperCase(); 349 imageObj.src = img_url; 350 imageObj.height = 216; 351 imageObj.title = title.toUpperCase(); 350 352 imageObj.country = imageObj.title; 351 imageObj.id = "flag-img-" + i;353 imageObj.id = "flag-img-" + i; 352 354 353 355 $displayDiv.append(imageObj); … … 358 360 359 361 362 function calcSimilarityValuesChain(newFlagQuantHSLHist, 363 chain_count, img_obj_list, img_obj_list_len, 364 progressVal, progress_step, 365 $progressArea,$progressBar) 366 { 367 var imgObj = img_obj_list[chain_count]; 368 369 var existingQuantHSLHist = imgObj.quantHSLHist; 370 371 var similarity_score = quantizedColourHistogramComparison(newFlagQuantHSLHist,existingQuantHSLHist); 372 similarity_score = Math.round(similarity_score * 100) / 100; // round to 2 decimal places 373 similarity_score *= 100; // express as percentage 374 375 imgObj.similarityScore = similarity_score; 376 var img_title = imgObj.country; 377 378 if (isoCountryCodes != null) { 379 var country_code = imgObj.country; 380 img_title = isoCountryCodes[country_code] + " (" + country_code + ")"; 381 } 382 imgObj.title = img_title + ", Similarity score: " + similarity_score + "%"; 383 if (similarity_score>50) { 384 //imgObj.style.display = "block"; 385 //imgObj.style.visibility = "visible"; 386 } 387 else { 388 //imgObj.style.display = "none"; 389 //imgObj.style.visibility = "hidden"; 390 } 391 392 393 394 if (chain_count < img_obj_list_len-1) { 395 progressVal += progress_step; 396 if ($progressBar.progressbar) { 397 $progressBar.progressbar('value',progressVal); 398 } 399 400 setTimeout(function() 401 { calcSimilarityValuesChain(newFlagQuantHSLHist, 402 chain_count+1,img_obj_list, img_obj_list_len, 403 progressVal, progress_step, 404 $progressArea,$progressBar) 405 } 406 ,1 // any time delay causes break in 'rendering' thread, even 0! 407 ); 408 409 } 410 else { 411 // done 412 $progressArea.find('span:first').text("Done."); 413 if (img_obj_list_len>show_progress) { 414 progressVal = 100; 415 if ($progressBar.progressbar) { 416 $progressBar.progressbar('value',progressVal); 417 } 418 $progressArea.slideUp(); 419 } 420 } 421 422 } 360 423 361 424 function calcSimilarityValues(newFlagQuantHSLHist, $displayDiv,$progressArea,$progressBar) … … 368 431 369 432 var img_obj_list_len = img_obj_list.length; 433 console.log("*** img obj list len = " + img_obj_list_len); 370 434 371 435 if (img_obj_list_len==0) { … … 377 441 } 378 442 379 var progress_step = 100.0 / img_obj_list_len;380 381 443 for (var i=0; i<img_obj_list.length; i++) { 382 444 var imgObj = img_obj_list[i]; 445 imgObj.style.display = "inline"; 446 //imgObj.style.visibility = "visible"; 447 } 448 449 var progress_step = 100.0 / img_obj_list_len; 450 /* 451 var chain_count=0; 452 453 setTimeout(function() { 454 calcSimilarityValuesChain(newFlagQuantHSLHist, 455 chain_count, img_obj_list, img_obj_list_len, 456 progressVal, progress_step, 457 $progressArea,$progressBar) 458 } 459 ,100 460 ); 461 */ 462 463 464 for (var i=0; i<img_obj_list.length; i++) { 465 var imgObj = img_obj_list[i]; 383 466 384 467 var existingQuantHSLHist = imgObj.quantHSLHist; 385 468 386 469 var similarity_score = quantizedColourHistogramComparison(newFlagQuantHSLHist,existingQuantHSLHist); 470 similarity_score = Math.round(similarity_score * 100) / 100; // round to 2 decimal places 471 similarity_score *= 100; // express as percentage 472 387 473 imgObj.similarityScore = similarity_score; 388 imgObj.title = imgObj.country + ", Similarity score: " + similarity_score; 474 var img_title = imgObj.country; 475 476 if (isoCountryCodes != null) { 477 var country_code = imgObj.country; 478 img_title = isoCountryCodes[country_code] + " (" + country_code + ")"; 479 } 480 imgObj.title = img_title + ", Similarity score: " + similarity_score + "%"; 481 if (similarity_score>50) { 482 //imgObj.style.display = "inline"; 483 //imgObj.style.visibility = "visible"; 484 } 485 else { 486 //imgObj.style.display = "none"; 487 //imgObj.style.visibility = "hidden"; 488 } 389 489 390 490 progressVal += progress_step; 391 console.log("*** i = " + i);392 console.log("*** pbar = " + $progressBar.progressbar);491 //console.log("*** i = " + i); 492 //console.log("*** pbar = " + $progressBar.progressbar); 393 493 if ($progressBar.progressbar) { 394 494 $progressBar.progressbar('value',progressVal); … … 402 502 $progressArea.slideUp(); 403 503 } 504 505 404 506 } 405 507
Note:
See TracChangeset
for help on using the changeset viewer.