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" :
And I want to find the red dot "center of mass" as a Point(x,y)
.
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" :
And I want to find the red dot "center of mass" as a Point(x,y)
.
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.
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.
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?
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>
If anything more is needed please do notify me, I have to submit this in 3 hours. Thank you
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;
}
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
Is there any efficient method to access and change image pixels than the usual scanning the pixel array and changing them? I've a psuedocode but I want a a better method than this. I just need an algorithm, any language is fine. It looks something like this:-
For i in range(0,len(pixel_array),4)
pixel_array[0] = a //a is some random value
pixel_array[1] = a
pixel_array[2] = a
pixel_array[3] = 1
i designed a simple website using joomla and i'm currently using beez3 template. i would like to add a simple image that can be clicked (as a hyper textual link) inside a module and place such module in a given position inside my template.
for such purpose, i created a new custom html module and placed inside it the following code:
<p><a href="http://ift.tt/1F7udTx">
<img src="images/hotel.jpg" alt="" width="250" height="180" /></a></p>
the image appears correctly where i wish, but it's surrounded by a kind of tab, whose title is the same i chose for module, that can be clicked, even if nothing happens when i do it. Here's how image appears, surrounded by tab (PARTNERS is the title i chose for module)
do you know how to remove such tab and its borders surrounding image?
thanks for help.
I have a upload button and I want users being able to preview the image before clicking 'save'. I have
<input type="file" accept="image/*" id="avatarInput" onchange="PreviewImage();"/>
as my HTML and for my JS:
function PreviewImage() {
var oFReader = new FileReader();
oFReader.readAsDataURL(document.getElementById("avatarInput").files[0]);
oFReader.onload = function (oFREvent) {
$('.image').attr('src', oFREvent.target.result);
};
};
But now, when I try to upload portrait image on my mobile, the preview image is rotated 90 degree. How can I cope with this? I've seen this and this but I don't know the codes can be incorporated in my case. Thanks.
I have a very simple question : my image does not load with that simple code.. do you have any explanation ?
<!DOCTYPE html>
<html>
<body>
<h2>my image</h2>
<img src="C:\Users\Public\Pictures\Sample Pictures\desert.jpg" alt="image"/>
</body>
</html>
Note : i am working locally on my computer using WampServer
I am 100% sure of the path (it displays the image if I copy/paste it directly in the url bar of firefox). I also tried to put the image directly in the same folder as the html file... I tried with firefox/chrome/IE with no success.
Something strange though : it works if I use online image...
I am attempting to convert a PPM image to PGM and loop through the image at each pixel do double avg etc...
#include <stdio.h>
#include "image-io.h"
int main(int agrc, char **argv)
{
int i, j;
if (agrc != 3) {
fprintf(stderr, "Usage: %s infile outline\n", argv[0]);
fprintf(stderr, "Reads PGM or PPM from infile,"
"writes identical image to outline \n");
return EXIT_FAILURE;
}
pm_init(argv[0], 0);
struct image *img = read_image(argv[1]);
fprintf(stderr, "input image is %dx%d, depth=%d, maxval=%d\n",
img->pam.height, img->pam.width,
img->pam.depth, (int) img->pam.maxval);
img->pam.format = RPGM_FORMAT;
img->pam.depth = 1;
for ( i = 0 ; i < img->pam.height; i++) {
for ( j = 0 ; j < img->pam.width; j++) {
double avg = (img->r[i][j] +img->g[i][j] + img->b[i][j]) /3.0;
img->g[i][j] = (int) (0.5 + avg);
}
}
write_image(argv[2], img);
free_image(img);
return EXIT_SUCCESS;
}
I am having issue looping over the image
I'm looking for a way to display the img
title & alt
tags in a div
(.image-caption
).
This is my code so far:
owl.on('changed.owl.carousel', function(event) {
var comment = $(this).find('img').attr('alt');
var title = $(this).find('img').attr('title');
if(comment) $('#desktop .image-caption').html('<h4>'+title+'</h4><p>'+comment+'</p>');
})
Any ideas? Thanks!
I have created an sample code to see an image in different resolution such as tablet, mobile and desktop, the code is working but actually I want to see all these resolution within the desktop itself which is not working . My code is as given below
Can anyone please tell me some solution for this.
Css
@media only screen and (max-width : 480px) {
/* Smartphone view: 1 tile */
.box1 {
width: 480px;
padding-bottom: 100%;
}
}
@media only screen and (max-width : 650px) and (min-width : 481px) {
/* Tablet view: 2 tiles */
.box2 {
width: 50%;
padding-bottom: 50%;
}
}
@media only screen and (max-width : 1050px) and (min-width : 651px) {
/* Small desktop / ipad view: 3 tiles */
.box3 {
width: 33.3%;
padding-bottom: 33.3%;
}
}
@media only screen and (max-width : 1290px) and (min-width : 1051px) {
/* Medium desktop: 4 tiles */
.box4 {
width: 25%;
padding-bottom: 25%;
}
}
For my website we use custom style sheets that are stored locally on our server and are injected into the webpages. However when i add them to CKEditor and then attempt to resize or move an image with the enhanced image plugin they cannot be resized or moved at all. Has anyone encountered this problem before? Is there anyway around it?
Building a WordPress theme and trying to crossfade multiple background images on the body tag and not on a div! I have been trying to use the tutorial here: http://ift.tt/1o25R5v | Demo 3 with no success
Is it possibe to do without javascript and jquery and just use css only! Currently my Body css looks like this....
body {
font-family: 'Arial', courier, sans-serif;
background:url('ASSETS/bg2.jpg')no-repeat top left;
background-size:cover;
background-attachment:fixed
}
I do have another image to crossfade in my ASSETS folder called bg.jpg.
amigos!
The problem is as follows: I have a set of images (url addresses). Some of them are of acceptable size, but some are too big. When I load it, app crashes because of big images. Is there a way to learn image size (megabytes) preliminarly? This way I can remove large images from the list, avoiding it to be loaded.
Thanks for attention.
I am having trouble adjusting images in blog articles in mobile theme. Somehow they are messing up the layout. I use the following code for images in articles.
1) <div class="leftbox"><img src="http://.mysite.net/blog/media/Photo/Indian_tourists.jpg" width="400" height="267" alt="Indian tourists" title="Indian tourists" /></div>
2) <div style="text-align: center"><img src="http://ift.tt/1J2yaLv" width="520" height="347" alt="Surfing in France" title="Surfing in France" /></div>
I have added these codes to ensure that images don't alter the width but it seems they are not working.
.post_content img { height: auto !important; max-width: 100% !important; }
.leftbox img { height: auto !important; max-width: 100% !important; }
This is example of a link where image would stretch on mobile devices - http://ift.tt/1JmlNqx
I need your help please. I'm working in Matlab and I have tow images one with size 256*256 and the other one with size 64*64. I want to embed the small image into the first one but i would like to control the position of the embedding process. For example having the small image in the corner of the big image and then I want to change it in the middle ... do you have any idea how ? thank you
My task is to upload image & display path of the image to the user, i have the following snippet but its not showing the path of the image, instead it is throwing null pointer exception in at the location of storage path, though i put generic as default path
try {
String storagePath ="generic";
//String storagePath ="";
if(storagePath!= null)
{
if (fileType.equalsIgnoreCase("emailTemplateImagePathUrl")
|| fileType.equalsIgnoreCase("images"))
storagePath = configurationSettings
.getEmailTemplateImagePathUrl();
else if (fileType.equalsIgnoreCase("profileImagePathUrl"))
storagePath = configurationSettings.getProfileImagePathUrl();
else if (fileType.equalsIgnoreCase("imagePathUrl"))
storagePath = configurationSettings.getImagePathUrl();
else if (fileType.equalsIgnoreCase("postsImagePathUrl"))
storagePath = configurationSettings.getPostsImagePathUrl();
else if (fileType.equalsIgnoreCase("mantrasImagePathUrl"))
storagePath = configurationSettings.getMantrasImagePathUrl();
else if (fileType.equalsIgnoreCase("zodiacSignImagePathUrl"))
storagePath = configurationSettings.getZodiacSignImagePathUrl();
else if (fileType.equalsIgnoreCase("assetsBaseURL"))
storagePath = configurationSettings.getAssetsBaseURL();
else if (fileType.equalsIgnoreCase("assetsFolderName"))
storagePath = configurationSettings.getAssetsFolderName();
else if (fileType.equalsIgnoreCase("imagesFolderName"))
storagePath = configurationSettings.getImagesFolderName();
else if (fileType.equalsIgnoreCase("templeAssetsPrimaryFolderName"))
storagePath = configurationSettings
.getTempleAssetsPrimaryFolderName();
else if (fileType.equalsIgnoreCase("templeGalleryFolderName"))
storagePath = configurationSettings
.getTempleGalleryFolderName();
else if (fileType.equalsIgnoreCase("servicesFolderName"))
storagePath = configurationSettings.getServicesFolderName();
else if (fileType.equalsIgnoreCase("nearByFolderName"))
storagePath = configurationSettings.getNearByFolderName();
else if (fileType.equalsIgnoreCase("thumbnailsFolderName"))
storagePath = configurationSettings.getThumbnailsFolderName();
//String folderName = "C:\\Users\\Anupd\\workspace2\\Devalayam\\WebContent\\" + storagePath + "\\" + fileName;
String folderName = "C:\\Users\\Anupd\\workspace2\\Devalayam\\WebContent\\" + storagePath + "\\" + fileName;
System.out.println(storagePath);
System.out.println(folderName);
}
//String uploadFileLocation = folderName + storagePath + fileName;
String uploadFileLocation = storagePath ;
System.out.println(uploadFileLocation);
OutputStream out = new FileOutputStream(
new File(uploadFileLocation));
int read = 0;
byte[] bytes = new byte[1024];
while ((read = uploadInputStream.read(bytes)) != -1) {
out.write(bytes, 0, read);
}
uploadInputStream.close();
out.flush();
out.close();
// http://ift.tt/1J2ydae
out = null;
System.gc();
File file = new File(uploadFileLocation);
mapObject.put("fileName", fileName);
mapObject.put("fileType", fileType);
String strLong = Long.toString(file.getTotalSpace());
mapObject.put("fileSize",strLong);
} catch (IOException e) {
e.printStackTrace();
}
return g.toJson(mapObject);
& the op is null
C:\Users\Anupd\workspace2\Devalayam\WebContent\null\17f96f04-169b-47e4-9128-a326adfd2e1a-medium.jpeg
null
thanks in advance