Assistance with image conversion program.
hello,
I am relatively new to java so have already requested some help within the "new to java" section of the forum but wondered if it might be more appropriate to post my question in here? anyway...
I am trying to write a program which will convert a color image into a greyscale image. I have managed to get my code to compile but the output i receive is not what i expected. When running the conversion it produces a black image. The idea is to create an array, use pixelgrabber to place each pixel into this array, get the red, green, and blue values, convert into greyscale, add these coverted pixels to an array and make a new image from these. My code is below:
class SaveGreyMenuListnr implements ActionListener {
private ImagePanel panel = null;
SaveGreyMenuListnr (ImagePanel pn) {
panel = pn;
public void actionPerformed (ActionEvent ae) {
Image displayed = panel.getDisplayImage();
int width = displayed.getWidth(panel);
int height = displayed.getHeight(panel);
int pixels[] = new int[width*height]
PixelGrabber pg = new PixelGrabber(displayed, 0, height, width, height, pixels, 0, width);
try{
pg.grabPixels();
} catch (InterruptedException e) {
System.err.println("interrupted waiting for pixels");
for (int i = 0; i < (width*height); i++){
Color myColor = new Color(pixels);
int Red = myColor.getRed();
int Green = myColor.getGreen();
int Blue = myColor.getBlue();
double temp = 0.56 * (double)Green + 0.33 *(double) Red + 0.11 *(double) Blue;
myColor = new Color((int)temp,(int)temp,(int)temp);
int compressedInt = myColor.getRGB();
pixels[i] = compressedInt;
Image image = panel.getToolkit().createImage(new MemoryImageSource(width,height,pixels,0,width));
panel.setDisplayImage(image);
panel.repaint();
I think an issue is arising when using the getRed getGreen and getBlue methods... for example If i request System.out.println(Red); then a stream of 0's are shown on the command line.
Not 100% sure if this is the issue or if it is further back in my code. Any help would be greatly appreciated
cheers
Nope, don't crosspost. Please stay in your [original thread|http://forums.sun.com/thread.jspa?threadID=5350452&messageID=10520330#10520330]. I'm locking this one.
Similar Messages
-
Problem with image rendering program
I am trying to use a 3D image segmentation program called "ITK-SNAP" on Mac Mini (2013). However, when I loaded the image, half of the image is not showing. I have tried the program on OSX 10.8.5 and OSX 10.9.1 (same computer, just upgraded yesteday), and both OS gave me the same problem. I have also tried different versions of "ITK-SNAP", and that did not seem to help either. The specs for the Mac Mini is the following:
Processor: 2.5 Hz Intel Core i5
Memory 4GB 1600 MHz DDR3
Graphics: Intel HD Graphics 4000 1024MB
Software OSX 10.9.1 (13B42)
I was able to use this program without a problem on an older Macbook Pro laptop (2009, with OSX 10.8.5). The specs for the laptop is the following:
Porcessor: 2.4 Hz Intel Core 2 Duo
Memory: 3GB 1067MHZ DDR3
Graphics: NVIDIA GeForce 9400M 256MB
Software OSX 10.8.5 (12F45)
Does anyone have any suggestions on how to fix this? Is it necessary to reinstall some drivers?
Thanks in advance.
EdwardThe Nvidia GeForce GPU in the MacBook can handle the 3d. The HD4000 Intel in the Mini can't UNLESS you bump up your system RAM to 8Gb or 16Gb.
Here's why. The Nvidia is a dedicated chip, and it doesn't rely solely on system RAM to operate. The Intel HD4000 does. The MORE system RAM you have, the MORE video RAM you'll have with the Intel chip. I have 16Gb and my VRAM is 1024Mb. I use Photoshop CS5 and CS6. With 4Gb RAM, I don't have enough VRAM for either to enable 3D drawing. With 512Mb VRAM (8Gb system RAM), CS5 would allow 3D, but only with software rendering, and CS6 wouldn't allow it at all. Once I put 16Gb in the Mini, BOTH allow 3D rendering with hardware. -
Church needing assistance with data conversion.
We are a small Catholic Church in Royal Oak, MI. Last May our computer died and in the process of getting a new one we lost all of our weekly envelope collection data. We have all the paper copies and have been able able to scan one or two sheets in (as a test) and get a good PDF document. Would your product Export PDF create a working Excel file for us? How do we go about getting a test of the application before actually committing to a year subscription? Since we are right now in a situation of fulfilling contribution statements would we be able to do multiple documents at a time (we have five months of documents)? Is there any other (cheaper, quicker, easier) method that I should explore?
Thank you.
Jane McKay
St. Dennis Catholic Church
Royal Oak, MI.Good day Jane,
You could try to convert one of your PDF files by logging into the ExportPDF site with your Adobe ID credentials (the same email address you used to post here). You'll be presented with the opportunity to try one sample conversion! Try converting your PDF file to Excel.
Regarding your other questions, you cannot submit multiple documents at a time. Each document must be submitted, and the converted file downloaded before you can proceed with the next file. You may want to also consider Adobe Acrobat X. Acrobat X (either Standard or Professional) will allow you to convert your documents to Excel in a batch process, however it is a more expensive offering. We offer a free 30-day trial of Adobe Acrobat X Professional for Windows here: http://www.adobe.com/go/tryacrobatpro/
Please let me know if you have any other questions!
Kind regards,
David
Acrobat Community Manager
Adobe Systems -
Assistance with Imaging windows 7 via windows PE
Hi All.
I require help imaging windows 7 with windows PE.
I have a correctly set up bootable UFD with all PE and imagex files on it.
I have created and prepared the windows 7 installation for imaging and have sysprepped it.
When trying to capture the image to the UFD, it will capture but lasts 3 seconds and produces an 8mb file.
Why is it not capturing the whole image? There are no errors displayed.
I am using the command
F:\imagex /compress fast /check /capture c: f:\install.wim "Windows 7" "Windows 7 Image"Hi Jarad,
We hope your issue has been resolved, if you've found solution by yourself. We would appreciate it if you could share with us and we will mark it as answer.
Drive letter might be not same as Windows Explorer under Windows PE, please follow Tripredacus suggestion using disk part check again.
Regards
D. Wu
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact [email protected] -
Problems with image conversion from InDesign to PDF
My images look posterized when I convert from InDesign to PDF. Any ideas about this?
That'd be in the export settings not in Reader. Ask in the InDesign forum, they'll probably know better.
-
Need assistance with DateTime Conversion
I want to use the HttpSession.getCreationTime() value and write it to an Oracle Date field.
I am having trouble getting the value in the proper type and format.
I have a test servlet to try to understand the various ways to use and convert DateTime values.
Here's the code:
response.setContentType("text/html");
java.io.PrintWriter out = response.getWriter();
HttpSession session = request.getSession();
long logontime = session.getCreationTime();
SimpleDateFormat formatter = new SimpleDateFormat("mm-dd-yyy hh:mm:ss");
java.sql.Date sqlDate = new java.sql.Date(logontime);
String sDate = formatter.format(sqlDate);
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet</title>");
out.println("</head>");
out.println("<body>");
out.println("DateTime in Milliseconds: " + session.getCreationTime() + "<br>");
out.println("DateTime as java.sql.Date: " + sqlDate + "<br>");
out.println("java.sql.Date SimpleDateFormat: " sDate "<br>");
out.println("</body>");
out.println("</html>");
out.close();
Here's the output:
DateTime in Milliseconds: 1016812138284
DateTime as java.sql.Date: 2002-03-22
java.sql.Date SimpleDateFormat: 48-22-2002 10:48:58
What's happening with the Month in the SimpleDateFormat output?
Also,
How can I convert this string into a valid Date Object to use in CallableStatement.setDate(int index, Date x)?
Thank you for your help.Solved the problem too. Thanks for those who helped out.
Here's the final code:
HttpSession = request.getSession;
long logontime = session.getCreationTime();
SimpleDateFormat formatter = new SimleDateFormat("MM-dd-yyy hh:mm:ss a");
java.sql.Date sqlDate = new java.sql.Date(logontime);
String sDate = formatter.format(sqlDate);
try{
java.util.Date dateTime = formatter.parse(sDate);
sqlDate = new java.sql.Date(dateTime.getTime));
catch(java.text.ParseException ignore){}
now sqlDate can be used with CallableStatement.setDate(1,sqlDate) to write the value to the Oracle table. -
Problems converting PDF to MS Word document. I successfully converted 4 files and now subsequent files generate a "conversion failure" error when attempting to convert the file. I have a large manuscript and I separated each chapter to assist with the conversion; like I said, first 4 parts no problem, then conversion failure. I attempted to convert the entire document and same result. I specifically purchased the export to Word feature. Please assist. I initially had to export the Word Perfect document into PDF and attempting to go from PDF to MS Word.
Hi sdr2014,
I'm sorry to hear your conversion process has stalled. It sounds as though the problem isn't specific to one file, as you've been unable to convert anything since the first four chapters converted successfully.
So, let's try this:
If you're converting via the ExportPDF website, please log out, clear the browser cache, and then log back in. If you're using Reader, please choose Help > Check for Updates to make sure that you have the most current version installed.
Please let us know how it goes.
Best,
Sara -
I Have a Mac 10.9.5 I have Photoshop CS 5.. Also have Photoshop CC. As of last month was able to edit any image with either program,as of today I can't edit images in either program. I can't see and editing I've done ,but when close the image both program ask (do you want to save changes) I look at the image I don't see any changes to save. Please help Thanks for time in advance
Please describe the steps involved in the issue exactly (with screenshots maybe).
What have you done for trouble-shooting so far?
http://blogs.adobe.com/crawlspace/2012/07/photoshop-basic-troubleshooting-steps-to-fix-mos t-issues.html -
Conversion program generated with errors
in lsmw idoc method at the step 11 convert data iam getting error as conversion program generated with errors can some body help me .i assigned port ,partnertype and partner number and activated inbound processing but still getting this error.somebody pls help me its urgent.
Hi Mamidi,
Go to the LSMW you have choosen and if it is Recording Method you are getting this error.
Select Goto-->Recordings.
Select the Recording you have choosen in the Edit Mode.
Click on the Defaults All Button and save the recording.
Now go to the option Convert Data and check .
You will receive a message ..Conversion program successfully generated.
Thanks,
Sri -
I downloaded Adobe Acrobat XI Pro - I signed in and now all I get is the Adobe Download Assistant with a prompt to keep downloading the program or help page. How can I launch the actual program and not the Assistant?
Under the download or application file I only have the Assistant programMoving this discussion to the Acrobat Installation & Update Issues forum.
Isabellasf have you ran the installation files which were downloaded? By default they are downloaded to the download folder within your User folder. -
I have a licensed copy of Adobe Acrobat X Pro for Windows. I recently switched over to MAC OS and would like to move my Adobe X Pro over but the CD will not work for Mac OS? Can anyone assist me with this conversion?
Best,
James.you cannot use your pc license to install on a mac. you would need a separate license (and serial number) for that.
adobe allows platform swaps, but only with the latest (xi) version, Order product | Platform, language swap
your option to use acrobat on a mac are to upgrade to acrobat pro xi and change platforms, use a windows emulator (parallels/boot camp etc) on your mac or swap with a third party. -
Conversion from word problems with images
Hi ,
I managed to make a conversion table to structure the documents of out company.I am having a proble with images.I am importing the word file to our template with a custom EDD document.When the import finishes I am having all images at almost correct places.The issue is when i apply the custom conversion table all the images at anchored at insertion point.The correct position would be at below current line.I am stuck and I can not find a solution to this.
My EDD is as follows:
EDD Version is 12.0
Structured Application: ReportPlain
F:\FramemakerBooks\Part B -Section 3.fm
April 14, 2014
Element (Container): Author
General rule: <TEXT>
Text format rules
In all contexts.
Use paragraph format: ReportAuthor
Element (Container): Emphasis
General rule: <TEXTONLY>
Text format rules
In all contexts.
Text range.
Use character format: Emphasis
Element (Equation): Equation
Element (Container): EquationPara
General rule: Equation
Text format rules
Element paragraph format: Equation
Element (Container): Extract
General rule: (<TEXT> | Emphasis | Term | Superscript | Subscript | XRef)*
Attribute list
Name: ID Unique ID Optional
Text format rules
In all contexts.
Use paragraph format: Extract
Element (Container): Figure
General rule: (<TEXT> | Frame)*
Attribute list
Name: ID Unique ID Optional
Name: XRefLabel String Optional
Default: Figure
Name: Imported Choice Optional
Choices: Yes, No
Default: No
Text format rules
In all contexts.
Use paragraph format: Figure
Element (Footnote): Footnote
General rule: <TEXT>
Text format rules
In all contexts.
Use paragraph format: Footnote
If context is: * < Table
Use paragraph format: TableFootnote
Element (Graphic): GRAPHIC
Initial graphic element format
In all contexts.
Insert anchored frame.
Anchored Frame Object Style:FiguredCentered
Element (Graphic): Frame
Initial graphic element format
If context is: Figure[Imported = "Yes"]
Insert imported graphic file.
Else
Insert anchored frame.
Element (Container): Head
General rule: <TEXT>
Text format rules
Count ancestors named: Section
If level is: 1
Context label: H1
Use paragraph format: Heading1
Else, if level is: 2
Context label: H2
Use paragraph format: Heading2
Else, if level is: 3
Context label: H3
Use paragraph format: Heading3
Else, if level is: 4
Context label: H4
Use paragraph format: Heading4
Else, if level is: 5
Context label: H5
Use paragraph format: HeadingRunIn
Else
Numbering properties
Autonumber format:
If context is: {first} < Report
Use paragraph format: ReportTitle
Else, if context is: HeadingRunIn
Use paragraph format: HeadingRunIn
Element (Container): HeadingRunIn
General rule: Head, Para+
Element (Container): Item
General rule: (<TEXT> | Emphasis | Term | Superscript | Subscript | XRef | Para)*
Format rules for first paragraph in element
If context is: List[Type = "Plain"]
No additional formatting.
Else, if context is: List[Type = "Bulleted"]
Use paragraph format: Bulleted clean
Else, if context is: {first}
Use paragraph format: Numbered1
Else
Use paragraph format: Numbered
Element (Container): List
General rule: Item+
Attribute list
Name: ID Unique ID Optional
Name: Type Choice Optional
Choices: Plain, Bulleted, Numbered
Default: Bulleted
Automatic insertions
Automatically insert child: Item
Element (Container): Para
General rule: (<TEXT> | Emphasis | Term | Superscript | Subscript | XRef | Footnote | Table )*
Attribute list
Name: ID Unique ID Optional
Text format rules
If context is: {after Head }
Use paragraph format: Body
Else, if context is: {after List}
Use paragraph format: BodyAfterHead
Else
Use paragraph format: Body
Element (Container): Part
Valid as the highest-level element.
General rule: (Para | Footnote | Table | Section )*
Attribute list
Name: ID Unique ID Optional
Control flags: Read-only
Automatic insertions
Automatically insert child: Head
Text format rules
Element paragraph format: Body
Element (Container): Purpose
General rule: <TEXT>
Text format rules
Element paragraph format: ReportPurpose
Element (Container): Section
General rule: (Section,Head |Section | Para | List | Table | Figure | HeadingRunIn )*
Attribute list
Name: ID Unique ID Optional
Name: XRefLabel String Optional
Default: Section
Automatic insertions
Automatically insert child: Head
Element (Container): Subscript
General rule: <TEXTONLY>
Text format rules
In all contexts.
Text range.
Font properties
Superscript/Subscript: Subscript
Element (Container): Superscript
General rule: <TEXTONLY>
Text format rules
In all contexts.
Text range.
Font properties
Superscript/Subscript: Superscript
Element (Table): Table
General rule: TableTitle?, TableHead?, TableBody
Attribute list
Name: ID Unique ID Optional
Control flags: Read-only
Name: XRefLabel String Optional
Default: Table
Control flags: Read-only
Initial table format
In all contexts.
Table format: Format A
Element (Table Body): TableBody
General rule: TableRow+
Element (Table Cell): TableCell
General rule: (<TEXT> | Emphasis | Term | Superscript | Subscript | XRef | Frame| Para)*
Text format rules
Element paragraph format: Bodycell
Element (Table Heading): TableHead
General rule: TableHeadRow+
Element (Table Cell): TableHeadCell
General rule: <TEXT>
Element (Table Row): TableHeadRow
General rule: TableHeadCell+
Element (Table Row): TableRow
General rule: TableCell+
Element (Table Title): TableTitle
General rule: <TEXT>
Text format rules
Element paragraph format: TableTitle
Element (Container): Term
General rule: <TEXTONLY>
Text format rules
In all contexts.
Text range.
Use character format: Emphasis
Element (CrossReference): XRef
Attribute list
Name: IDRef ID Reference Required
Control flags: Read-only
Limit values for format change list properties
First indent
Maximum: 39.0"
Minimum: 0.0"
Left indent
Maximum: 39.0"
Minimum: 0.0"
Right indent
Maximum: 39.0"
Minimum: 0.0"
Space above
Maximum: 32767.0 pt
Minimum: -32767.0 pt
Space below
Maximum: 32767.0 pt
Minimum: -32767.0 pt
Line spacing
Maximum: 32767.0 pt
Minimum: -32767.0 pt
Tab stop position
Maximum: 39.0"
Minimum: 0.0"
Font size
Maximum: 400.0 pt
Minimum: 2.0 pt
Spread
Maximum: 1000.0%
Minimum: -1000.0%
Stretch
Maximum: 1000.0%
Minimum: 10.0%
Cell margins
Top
Maximum: 32767.0 pt
Minimum: 0.0 pt
Bottom
Maximum: 32767.0 pt
Minimum: 0.0 pt
Left
Maximum: 32767.0 pt
Minimum: 0.0 pt
Right
Maximum: 32767.0 pt
Minimum: 0.0 pt
And my conversion table is:
Wrap this object or objects In this element With this qualifier
TC: TableCell
P:Body Para
P:Normal Para
P:Heading 5 Head head5
E:Head[head5],(Para | Frame | List | Table )* Section section5
P:Heading 4 Head head4
E:Head[head4],(Para | Frame | List | Table | [section5])* Section section4
P:Heading 3 Head head3
Head[head3],(Para | List | Frame | Table | [section4])* Section section3
P:Heading 2 Head head2
Head[head2],(Para | List | Frame | Table | [section3])* Section section2
P:Heading 1 Head head1
Head[head1],(Para | List | Frame | Table | [section2])* Section section
T:Table Table (promote)
TT: TableTitle
TH: TableHead
TB: TableBody
TF: FOOTING
TR: TableRow
RE:RootElement Part
P:List Paragraph Item
Item+ List
G: GRAPHIC(promote)
RE:RootElement Part
I am almost done with the template"Application"I just need to place the pictures in the correct position.Can anyone point me to the right direction?
Thanks a lot in advanceDimitris,
I know you originally posted this question on the general FrameMaker forum. I suggest below that you post a follow-up question there.
The structure-based part of the issue is that neither a conversion table nor an EDD can change properties of an existing anchored frame. It seems that when you open your Word document in FrameMaker, the graphics come in positioned at the insertion point. That doesn't change when you apply the conversion table. Your EDD does specify object style FiguredCentered as the initial format for GRAPHIC elements. The keyword here is "initial". The EDD can indicate a style for new anchored frames that are created by inserting an element. It does not allow you to change existing anchored frames.
So the real problem is how to make a global change to all existing anchored frames (either assigning an object style or changing the position to Below Current Line) so that you don't have to change them one at a time. I am not aware of a way to do so with existing FrameMaker commands. You could use a script or plug-in, or save the document as MIF and make a global change with a text editor in the MIF file. You might ask on the general FrameMaker forum if someone there knows an easier approach.
--Lynne -
Having a problem converting a PDF file to Words with Adobe's conversion program.
Having a problem converting a PDF file to Words with Adobe's conversion program.
See https://forums.adobe.com/docs/DOC-2412
If you need more help, please ask in https://forums.adobe.com/community/acrobatdotcom/ -
Hi!
Would like to find out how a Pages document might be opened by a recipient that only has a PC with Windows and Microsoft Office. Is there a conversion program?Making changes to PDF file: Apple Support Communities
Have just noticed this in a thread today. The link from Klaus1's post may allow you to use PDF and work on it. I haven't tried it but it may give you some extra ammunition. -
hello everybody
is it possible to tell me how i can make program in labview that take pixels of black and withe image and give coordinate of black or white pixels back to me.
Solved!
Go to Solution.Here's a slightly simpler version.
(Depending how you want to process the output, you might not need to traspose and/or reverse. Boolean to 0,1 works directly on the 2D array if needed )
amkamyab wrote:
it is good. i could enter 1bit image in and show it in array. now i want to take pixels coordinates. i meen i want to have (x,y) of each pixel to send it pixel coordinate to another program i wrote for steppers motor.
Can you be a bit more specific on how the output is supposed to look like? Initially you wrote "black or white", and since all pixels are either black or white, do you want to send all pixels? In what format? In what order? Please clarify?
LabVIEW Champion . Do more with less code and in less time .
Attachments:
BW-Pix.png 8 KB
Maybe you are looking for
-
What do I need to do to use my iPad in Europe?
I am going to Europe and would like to take my iPad with me to check email, use the internet, get directions and use face time while there. My pad is equipped with 3G but I don't currently have a contract. Can I use wifi to do what I want?
-
HP Omni 10 5600US - Is there a USB to barrel connector charging cable?
As we all know, the power cable for the Omni10 5600US leaves much to be desired. Barrel connector. Fine Cant use the USB port to charge. Fine BUT...Is there a USB to barrel connector charging cable? Arent USB cables just basically wires arranged in a
-
ISA SSO problem, help!!
Our system landscape is as follows: 1. Portal(7.0 sp8) PGD host:pekax119.mycompany.com 2. CRM(2005) CGS host: crmdev01.mycompany.com Abap instance Java instance (ISA installed here) We want to integrate the ISA applications into P
-
How to view images which resides in the database using JFrame.
Hello defts, Im developing an application using swings. I need to display a image in a JFrame during an button click event. where that image resides in the database.
-
hi all, i have a bdc program, can anyone please tell me that how would i know the recording name? can anyone please help me that is there any possibility? regards saurabh. Edited by: saurabh srivastava on Dec 18, 2008 8:50 AM Edited by: saurabh sriva