Find color of specific pixels
I'm working with grayscale images and I need to find average darkness of specific regions. The areas are all perfectly circular.
I can't figure out how to determine the color of specific pixels in an image. Does anyone know of a way? I need to process millions of pixels so I would prefer something that can do this relatively quickly. The images are all grayscale, so I only really need to know the darkness of the pixel.
I don't suppose there is any built-in way of doing this that would be more efficient than my computing the average manually?
Ok, it seems that I can use a BufferedImage to acquire the colors of specific pixels. I found a couple methords that seem relavent:
public int getRGB(int x, int y)
public int[] getRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize)
The first is pretty staight forward, but I am interested in performance, and the second sounds like it could be better.
I'm not sure about the meaning of the the scansize argument:
scansize - scanline stride for the rgbArray
Am I right in thinking that rgbArray is defined that the value in the first index (after offset) is the upper left corner, the next is the pixel directly to the right of it. When the index become equal to scanline, you are now on the next row of pixels below.
This doesn't make sense to me because it would defeat the purpose of having 'w' (the width).
Now, the other question is whether using the second methord will actually improve performance...I need circular regions, so using a rectangle will waste data. Would I be better off using getRGB(int x, int y)? How about creating a subclass of BufferedImage designed to extract the colors in a circular manner. Actually, is using a BufferedImage the best approach even?
Similar Messages
-
How I find color of the pixel on the screen?, How I find color of the pixel on the screen?
DigitalColor Meter, in your Applications/Utilities folder.
Regards. -
Trouble finding Color of Pixel
Hello all,
I've put together a program which, should return "Success!" if the color if a pixel is equal to the value supplied in an if statement. The values are exactly the same, retrieved from the same pixel, but still when I run the program, the program returns the "else" statement, "Failure!" Does anyone know what the issue is? I'll post all the code as it is a very short program.
import java.awt.Component;
import java.awt.Graphics;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import javax.swing.*;
* This class demonstrates how to load an Image from an external file
public class Main extends Component {
Robot robot;
BufferedImage img;
public void paint(Graphics g) {
g.drawImage(img, 0, 0, null);
public Main() {
try {
robot = new Robot();
} catch (AWTException ex) {
try {
img = ImageIO.read(new File("/Users/george/Desktop/strawberry.jpg"));
} catch (IOException e) {
Color c = new Color(148, 152, 155);
public void search(){
System.out.println(c);
if (robot.getPixelColor(20,20) == c){
System.out.println("Success!");
}else{
System.out.println("Failure! The Color is:");
System.out.println(robot.getPixelColor(20,20));
public static void main(String[] args) {
JFrame f = new JFrame("Find Pixel");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Main main = new Main();
f.add(main);
f.setVisible(true);
main.search();
}Thanks! Any and all input is great. Also, if you know any good jokes, please share.
--JamesYour code is very confusing. Are you trying to access a pixel of the image or of the screen?
Anyway, the line
if (robot.getPixelColor(20,20) == c){should be
if (robot.getPixelColor(20,20).equals(c)){ -
I have a very simple question: Is it possible for applescript to sample the color of a specific pixel on my screen and store it in a variable? (or three variables as the case may be)
ThanksI knew I saw something like this earlier, but it took me a little while to find it.
There is a scripting addition called XTools that lets you move the mouse from AppleScript - it is available at http://lestang.org/osax/XTool/XTool-2.0.dmg.tgz . With XTools installed, it is a simple matter to move the mouse to where you want, then tell DigitalColor Meter to copy the color to the clipboard (it isn't scriptable, but you can use keystrokes):
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #FFEE80;
overflow: auto;"
title="this text can be pasted into the Script Editor">
move mouse {500, 500} -- requires XTool OSAX
tell application "DigitalColor Meter"
activate
tell application "System Events" to keystroke "c" using {shift down, command down}
end tell
log (get the clipboard)
</pre> -
The color of a pixel in Graphics
Hi... does anyone know how to get the Color of a specific pixel in a Graphics object??
For example:
public void paint(Graphics g) {
// Something like this would be great! (but it doesn't exist)
Color c = g.getColor(10,10);
/* etc... */
}Does anyone know something about it?http://www.rgagnon.com/javadetails/java-0257.html
-
To color a specific row in a Table UI element
Hello Experts,
We have a requirement to highlight (with distinguish color) a specific row of a table UI based on column data.
Suppose we have a table with 5 column and 10 row, now if the data on 5th column greater than some XYZ value then we need to highlight the specific row with a different color.
Can anyone please help me to achieve this requirement?
Thanks & Regards,
Sambaran ChakrabortyHi,
In your outline, I am missing quite a few prerequisites which I mentioned (not sure if you have implemented them already)
your sub node, does it have singleton=false, cardinality 1..1 and selection cardinality 1..1?
The attribute of type TableCellDesign in that sub node, does it have the calculated property to true?
If you've bound each table column's cellDesign property to this calculated attribute, you just put some code in the generated generated get<SubNode><CalcAttribute> method to set the color
For instance by just entering the line
return WDTableCellDesign.CRITICALVALUE_LIGHT
in that method will render each linked cell to that color
Not sure what else I can say to explain this, there's not much to code... -
How to change the color of specific row in ALV tree
Hi,
I m using method set_table_for_first_display of a class CL_GUI_ALV_TREE.
The req is to change the color of specific row. Now can anybody tell me how to change the color of ALV tree. As in ALV tree and in this method 'set_table_for_first_display', there is no parameter IS_Layout.
Pls suggest...hi
hope this code will help you.
Reward if help.
REPORT zsharad_test1.
TABLES: ekko.
TYPE-POOLS: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
line_color(4) TYPE c, "Used to store row color attributes
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid.
*Start-of-selection.
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
FORM build_fieldcatalog.
There are a number of ways to create a fieldcat.
For the purpose of this example i will build the fieldcatalog manualy
by populating the internal table fields individually and then
appending the rows. This method can be the most time consuming but can
also allow you more control of the final product.
Beware though, you need to ensure that all fields required are
populated. When using some of functionality available via ALV, such as
total. You may need to provide more information than if you were
simply displaying the result
I.e. Field type may be required in-order for
the 'TOTAL' function to work.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
fieldcatalog-do_sum = 'X'.
fieldcatalog-no_zero = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-col_pos = 5.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Order Unit'.
fieldcatalog-col_pos = 6.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-datatype = 'CURR'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-seltext_m = 'Price Unit'.
fieldcatalog-col_pos = 8.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
Build layout for ALV grid report
FORM build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
Set layout field for row attributes(i.e. color)
gd_layout-info_fieldname = 'LINE_COLOR'.
gd_layout-totals_only = 'X'.
gd_layout-f2code = 'DISP'. "Sets fcode for when double
"click(press f2)
gd_layout-zebra = 'X'.
gd_layout-group_change_edit = 'X'.
gd_layout-header_text = 'helllllo'.
ENDFORM. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
Display report using ALV grid
FORM display_alv_report.
gd_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
it_special_groups = gd_tabgroup
IT_EVENTS = GT_XEVENTS
i_save = 'X'
is_variant = z_template
TABLES
t_outtab = it_ekko
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
DATA: ld_color(1) TYPE c.
SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
UP TO 10 ROWS
FROM ekpo
INTO TABLE it_ekko.
*Populate field with color attributes
LOOP AT it_ekko INTO wa_ekko.
Populate color variable with colour properties
Char 1 = C (This is a color property)
Char 2 = 3 (Color codes: 1 - 7)
Char 3 = Intensified on/off ( 1 or 0 )
Char 4 = Inverse display on/off ( 1 or 0 )
i.e. wa_ekko-line_color = 'C410'
ld_color = ld_color + 1.
Only 7 colours so need to reset color value
IF ld_color = 8.
ld_color = 1.
ENDIF.
CONCATENATE 'C' ld_color '10' INTO wa_ekko-line_color.
wa_ekko-line_color = 'C410'.
MODIFY it_ekko FROM wa_ekko.
ENDLOOP.
ENDFORM. " DATA_RETRIEVAL -
Use smart mailbox to find email with specific text in attached pdf
Does anyone known if a smart mailbox can be created to find emails with specific text within a pdf attached document. I know that spotlight can do this and it works fine but it would suite me better to be able to do this in mail.
After some digging, I found that Spotlight returns the pdf attachment (found within the library/mail/download folder), but not the actual email. The only time it returns the email is if the search text or numerics are coincidentally within the written contents or subject line.
Yes, i have tried setting up smart mailbox search criteria using the entire message contents but this does not find emails where the text exist within the pdf.
I've checked spotlight pref.'s and all categories are checked off.
Essentally, i need the smartbox search criteria to return results where the search text is found within the pdf attachment if possible. If this is not possible, i'll continue using spotlight searches outside of mail.
I appreciate any help you can offer. -
This may be a basic question... but in InDesign, how does one determine the pixel size of a text box? Specifically, we need to write text to specifications of 600 pixel width, and have no idea a) how to scale a text box to specific pixel width, b) how to determine what word count we can fit in, and c) how to do it in a table? Thanks!
Set your ruler increments to pixels Preferences>Units & Increments. You can fill the text box with placeholder text Type>Fill with Placeholder text and get a word count from the Info panel with Show Options turned on from the flyout.
From the Transform panel you can set a text box's width and height -
Can't find color tab in speedgrade
Can't find color tab in speedgrade
Working with CS6? There it is still called Monitor and you'll find it to de left. Or you can use the shortcut D (once or twice depending where you start form).
-
How to display the rows in a color for specific dynamic condition.
Hi,
I am new to OAF. I created a custom Search Page.My requirement is we need to display a color for specific dynamic condition. Could any one help me how to do this?
Thanks in Advance
Sruthi.Hi,
Sruthi wrote:
I am new to OAF. I created a custom Search Page.My requirement is we need to display a color for specific dynamic condition. Could any one help me how to do this?------I think we can display colours at coloumns level only,nt at row levevl.
------use CSSStyle to set the colour, via webBean.
Co-ProcessRequest:*
import oracle.cabo.style.CSSStyle;
CSSStyle oraaniltext = new CSSStyle();
oraaniltext.setProperty("color", "#F6358A");
oraaniltext.setProperty("background-color", "#000000");
OAMessageTextInputBean comCode = (OAMessageTextInputBean)webBean.findChildRecursive("InvoiceIdTI");
comCode.setInlineStyle(oraaniltext);
http://www.computerhope.com/htmcolor.htm
Regards
Meher Irk
Edited by: Meher Irk on Oct 25, 2010 9:46 PM -
Set color of specific cells in JTable.
I have a JTable where I want to set the color for specific cells. Is this possible to do, and if so, how?
Well, one way is to create a custom renderer that know the background color of each cell in the table. The Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#renderer]How to Use Table has an example you might be able to build on.
Or, this posting may give you another approach. The key to both solutions is to somehow specify the color for every cell:
http://forum.java.sun.com/thread.jspa?forumID=57&threadID=610474 -
Hi,
I Want to know how i can know the color of a pixel in an image.
Please provide me with any information.
Regardshi,
u may get the color of a pixel by the following code
java.awt.Robot robot=new java.awt.Robot();
Color c=robot.getPixelColor(int X,int Y); -
How to define specific color for specific data in WebI?
Hi everybody,
I wonder how I could connect data shown in e.g. a vertical stacked bar chart to a specific color. The assignment of color in a chart is done by Webi automatically after pulling a a variable to a chart. Later on it is possible to change to color via the color palette. But how can I define a specific color for specific values of an attribute? (E.g. calue is Chicago -> color is blue; value is NY -> color is red.. etc ) Is it possible?
Does anybody know the trick?
Thanks in advance!Please refer the below links along similar lines .
[http://www.dagira.com/2007/07/22/alerters-on-charts/]
[http://www.dagira.com/2007/07/31/alerters-on-charts-part-ii/]
Regards,
Bilahari M -
I am looking to find out about specifications of the components of Hyper-V
Hi,
I am looking to find out about specifications of the components of Hyper-V, is someone able to reach out to me? Some features I am looking to find if Hyper-V covers (and the components that would be used) are:
Automated live migration
Workload balancing
Physical-to-virtual conversion
Plug-in for SCOM
Integrated StorageLink
Distributed Virtual Switch
Use of OpenStack?
Thanks,
EricYou can check with OpenStack to determine their support.
SCOM support of Hyper-V - check wit the SCOM team.
Automated Live Migration - this could be interpreted multiple ways. However I suspect you are looking for the SCVMM PRO feature.
Workload Balancing and StorageLink and Distributed Virtual Switch are feature / product names from companies other than MSFT - so you must elaborate on the use case.
Not sure what your intent is, but it reads as if there is some feature comparison you are trying to do between apples and oranges.
Brian Ehlert
http://ITProctology.blogspot.com
Learn. Apply. Repeat.
Maybe you are looking for
-
How to upload file from desktop or C drive and send as attachments
Hello Experts, Please tell me How to upload jpg or gif or drawing files from desktop or any drive and store into R/3 by the same time I have to send mail as a attachment. I heard that FM SO_NEW_DOCUMENT_ATT_SEND_API1 is only to send as a attachment
-
How to save a .csv file to database server
Hi every body, I need to upload a .csv file from the client machine and save it to a directory in a database sever. I could do the uploading part. Can anyone tell me how to save the file? Another option is save the file as a CLOB in a database column
-
It's not all phone numbers, but a significant number.
-
Posting live webcam online?
Random question, but is it possible to leave my computer on while I'm at work and have my built in iSight camera feed live to a website? I have .Mac, but didn't see anything about it on iWeb. I just got a dog, and want to be able to watch him while I
-
Can't install the newest version of iTunes...or anything else!
I just got a new macbook pro today, and it shipped with snow leopard and a slightly older version of iTunes than my older macbook had. the problem is I can't run iTunes as I get a message that says "The file "iTunes library" cannot be read because it