lundi 20 avril 2015

Core point of binary image

How to find the the center of mass or the core point (x,y) of a binary image using Java?
Lets say I have this Picture "Binary, ones=Green" :

enter image description here

And I want to find the red dot "center of mass" as a Point(x,y).

What are the standard methods for comparing image quality? [on hold]

I am trying to figure out what the standard methods for compare image quality are. I know of SNR, PSNR, RMSE, MAE, and SSIM.

However, I have also read a little bit about trying to model the human visual system because these metrics aren't the best. I've also heard about doing subjective testing, but that is not feasible for me.

Is there some standard set of image metrics are provided when comparing the quality of two images?

Specifically I am trying to reconstruct images collected with a sensor I built and I want to compare the gold standard to images I have with special filtering and image improvement techniques.

Select image and create object. Processing 2.0

here is a code snippet from my Image class:

class Image{

  public int width;
  public int height;

  public PImage img;

  Image(PApplet parent){

    width = 512;
    height = 512;

    img = new PImage();
    img = parent.loadImage("test.jpg");
    img.resize(width, height);
  }
}

I draw it in the main file in such a way:

image(image.img, 287, 280);

I'd like to choose the image having clicked it:

void mousePressed() {
   if (gui.btnOver1) {
     selectInput("Choose file:", "fileSelected");
   }
}

However, I don't know how to use this function in an OOP way:

void fileSelected(File selection) {
  if (selection == null) {
    println("Window was closed or the user hit cancel.");
  } else {
    img = loadImage(selection.getAbsolutePath());
    img.loadPixels();
  }
}

Thanks for help.

How to show image using smarty, when it is stored on amazon?

My images are stored on Amazon servers and I have to display them (using smarty) in a smarty template.
currently I am able to show an image using following PHP code:

header('Content-type:image/jpeg');  
header("Content-disposition: inline; filename=\"".basename($formatted_filename)."\"");

How could I show it on smarty page?

How to have 2 same functions in Javascript for 3 different images?

This is the code that I found online from someone and used it on my own HTML code.

<script type="text/javascript">// <![CDATA[
var image=new Array("/Users/ghanimbakhit/Desktop/HTML Project/images/rock.jpg",
"/Users/ghanimbakhit/Desktop/HTML Project/images/rock2.jpg",
"/Users/ghanimbakhit/Desktop/HTML Project/images/rock3.jpg");


var timeout={};
function stopIt(){
clearTimeout(timeout);
}
function changeimage(dvX){
var dvi=document.getElementById(dvX);
if(!dvi.count || dvi.count == image.length )
dvi.count=0;
dvi.src=image[dvi.count];
dvi.alt=image[dvi.count];
dvi.count=dvi.count+1;
timeout=setTimeout('changeimage("'+dvX+'")',3500);
}
// ]]></script>

And this is the body

<body onload="changeimage('changer')">
<div style="position:absolute;top: 600px"  ><img width="350" src="t1 alt="Rock Climbing"  id="changer"/></div>

This code is used to automatically change images in a few seconds, and I chose it so for some images "rock,rock2,rock3". I have 2 more images that I want the same function to be done with. How can I do that without overriding the above code? Im new to Javascript.

If anything more is needed please do notify me, I have to submit this in 3 hours. Thank you

Figcaption Not Aligning Correctly Under Image

I'm trying to layout 3 pictures one straight after another on the same line, each having their own 'Figcaption'. But the figcaption as seen in the image below is completely not centered and the figure area is not aligned correctly with the image either. I need the figure to take up exactly the same space as the image otherwise it's pushing the other images to the next line which I don't want happening. So basically, what would be the best way about setting the specific 131px size for the figure and then making the figcaption exactly aligned with the image when I set the text to align in the center?

Image of Problem - http://ift.tt/1blpMJh (The Figure is not aligned at all with the image)

HTML:

<!DOCTYPE html>
<html>

<head lang="en">
    <meta charset="UTF-8">
    <title>Lakeside Books</title>
    <link rel="stylesheet" type="text/css" href="masterstyle.css">
    <meta name="viewsize" content="width-device-width,initial-scale=1.0">

    <!--[if IE]>
    <script type="text/javascript" src="_http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

</head>

<body>
<div id="wrapper">
    <div id="sidebar">
        <nav id="nav">
            <h3 id="welcometext">Welcome To<br>Lakeside Books</h3>
            <div id="searchbar">
                <form action="http://ift.tt/1piqnAa">
                    <input type="text" name="search" placeholder="...Search Book Title"/>
                </form>
            </div>
            <ul>
                <li>
                    <a class="link">
                        Home
                    </a>
                </li>
                <li>
                    <a class="link">
                        Categories
                    </a>
                </li>
                <li>
                    <a class="link">
                        Bestsellers
                    </a>
                </li>
                <li>
                    <a class="link">
                        Contact
                    </a>
                </li>
            </ul>
        </nav>
    </div>

    <div id="sectionone">
        <div id="containerone">
            <div id="header">
                <div id="logo">
                    <h1>LAKESIDE BOOKS</h1>
                    <p>KERRYS LOCAL BOOKSTORE</p>
                </div>
            </div>
        </div>
    </div>

    <div id="sectiontwo">
        <div id="containertwo">
            <h2 id="sectwohead">Best Selling Books Right Now</h2>
                <div id="bestsellerimages">
                    <figure>
                        <img src="Images/4.jpg" alt="book1" height="200" width="131">
                        <figcaption>The Girl On The Train - Paula Hawkins</figcaption>
                    </figure>
                    <figure>
                        <img src="Images/3.jpg" alt="book2" height="200" width="131">
                    </figure>
                    <figure>
                        <img src="Images/5.jpg" alt="book1" height="200" width="131">
                    </figure>
                </div>
        </div>
    </div>

</div>
</body>
</html>

CSS:

html, body { /* ### */
    margin:0;
    padding:0;
    height:100%;
    width:100%;
}
body {
    background-color: #fdfdfd;
    font-family: Arial, "Open Sans", sans-serif-light, sans-serif, "Segoe UI";
}
#wrapper {
    width: 100%;
    height: 100%;
    margin:0 0 0 20%; /* ### */
}
#sidebar {
    background-color: #212528;
    position: fixed;
    width: 20%;
    height: 100%;
    top: 0;
    left: 0;
    overflow: hidden;
}
#nav {
    color: #DADADA;
    display: block;
    max-width: 100%;
}
#nav ul {
    padding-left: 0;
}
#nav li {
    list-style-type: none;
    margin: 0;
    padding: 0.75em 0 0.75em 0;
    text-align: center;
    max-width: 100%;
}
#nav li:hover {
    background:#333;
}
#nav li a {
    display: block;
    padding: 0.5em 0;
}
.link {
    text-align: right;
    margin-right: 25%;
    letter-spacing: 1px;
}
#welcometext {
    text-align: center;
    font-style: italic;
    text-transform: uppercase;
    font-size: 1em;
    margin-top: 2em;
}
#searchbar {
    width: 70%;
    margin-left: auto;
    margin-right: auto;
    padding: 1em 1em 0.5em 1em;
    text-align: right;
}
#searchbar input {
    max-width: 95%;
}
#sectionone {
    /*position: fixed;*/
    top: 0;
    right: 0;
    width: 80%;
}
#containerone {
    margin-top: 0;
    width: 80%;
    height: 100%;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
    border-bottom: 2px solid #DADADA;
    box-shadow: inset 0 -6px 0 0 #fdfdfd, inset 0 -8px 0 0 #DADADA;
}
#header {
    margin: 6em 0 6em 0;
}
#logo h1 {
    color: #ed786a;
    text-shadow: 0.1em 0.1em 0 rgba(0, 0, 0, 0.1);
    letter-spacing: 13px;
}
#logo p {
    margin-top: -0.6em;
    color: #888888;
    letter-spacing: 4px;
    font-size: 0.85em;
}
#sectiontwo {
    width: 80%;
    top: 0;
    right: 0;
}
#containertwo {
    width: 80%;
    height: 100%;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}
#sectwohead{
    margin: 2em 0 2em 0;
    color: #888888;
}
#bestsellerimages{
    float: left;
    display: inline-block;
    width: 100%;
    max-width: 100%;
    margin: 0 0 2em 0;
}
#bestsellerimages img{
    padding: 0 1em 0 1em;
}
#bestsellerimages figure{
    display: inline-block;
    width: 131px;
}

How to use image in WPF as resource?

I was googling, but I have not found what I need. I tried to use this code to use image resource(build action setted):

BitmapImage bi3 = new BitmapImage();
        bi3.BeginInit();
        bi3.UriSource = new Uri(@"Resources\wall.png", UriKind.RelativeOrAbsolute);
        bi3.EndInit();

it throws filenotfoundexception