JAI pixel value after dct operation

Hi. i've recently start to programming with JAI.
I've applied the dct Discrete cosine Transform to a source image.
My Problem is the follow: "How can i obtain the RGB value of each pixel from the resulting dct image".
Here's the code:
String filename = "C:\\...\viola.jpg";
RenderedImage src = (RenderedImage)JAI.create("fileload", filename);
ParameterBlock pb = (new ParameterBlock()).addSource(src);
PlanarImage dct = JAI.create("dct", pb, null);
int width  = dct.getWidth();
int height = dct.getHeight();          
double[] dctData =
dct.getData().getPixels(0, 0, width, height, (double[])null);
FloatDoubleColorModel cm = (FloatDoubleColorModel) dct.getColorModel();
/* I want to have the RGB int value of the first dctData pixel */
int rgbint = cm.getRGB(dctData[1])  /* here the problem*/When i runthe code the follow exception is thrown:
Exception in thread "main" java.lang.ClassCastException: java.lang.Double cannot be cast to [F
at javax.media.jai.FloatDoubleColorModel.getRGB(FloatDoubleColorModel.java:476)
at Menu.Interfaccia.DCTIDCTTransformer.main(DCTIDCTTransformer.java:107)How can i obtain the rgb value in the correct way?
Edited by: Anton87 on Feb 21, 2010 6:29 AM

My solution would be to work with the image in its raw format. Extract the image into a 2 dimensional array, loop throught the rows and columns and compare to your zero crossing window detector. after you have aquired the new image array, you set pixels that are next to an edge 0 and the rest #ffff. this will create a binary image (black and white) with the edges black and rest white. Be careful of your conventions used to determine what are edges. This may seem primitive, but thats just the way i think :P
-fastrike

Similar Messages

  • Loader changes the pixel value after loading as bitmap

    Hi all,
    My aim is to load two images and compare its color information pixel by pixel. For this purpose i used "flash.display.Loader" class to load the images, and once load completes i'll typecast the loaded content to bitmap object (loaderObj.content as Bitmap). Finally i'll get the bitmapdata from the bitmap of both the images and compare the pixels.
    Now the problem is the color information of the original image and the loaded bitmap is slightly different. For example the color value of pixels of the attached image image1.jpg is 0xDDDDDD for complete 1366x768. And for the same image when it is loaded as bitmap the color value of pixels are different from the original value (For some pixels only, not all pixels are different).
    I’ve given the source code and sample images.
    Please can anyone help me out how to resolve this issue?
    <?xml version="1.0" encoding="utf-8"?>
    <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                                                         xmlns:s="library://ns.adobe.com/flex/spark"
                                                         xmlns:mx="library://ns.adobe.com/flex/mx"
                                                         width="1376" height="800"
                                                         showStatusBar="false">
              <fx:Declarations>
                        <!-- Place non-visual elements (e.g., services, value objects) here -->
              </fx:Declarations>
              <fx:Script>
                        <![CDATA[
                                  private function loadBtn_ClickHandler():void{
                                            var file:File = new File(File.desktopDirectory.nativePath);
                                            file.addEventListener(Event.SELECT, onFileSelectionHandler);
                                            file.browseForOpen("Open an image",[new FileFilter("Images", "*.jpg;*.gif;*.png;*.jpeg")]);
                                  private function onFileSelectionHandler(ev:Event):void{
                                            var loadedFilePath:String = (ev.target as File).nativePath;
                                            loadImageAsBitmap(loadedFilePath);
                                  /* Load image as bitmap using Loader */
                                  private function loadImageAsBitmap(url:String):void{
                                            var loader:Loader = new Loader();
                                            // load content as bitmap
                                            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onContentLoadComplete);
                                            loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onContentLoadFail);
                                            loader.load(new URLRequest(url));
                                  private function onContentLoadComplete(ev:Event):void{
                                            var loaderInfo:LoaderInfo = ev.target as LoaderInfo;
                                            var bitmap:Bitmap = loaderInfo.content as Bitmap;
                                            printPixelValue(bitmap.bitmapData);
                                            container_ID.addChild(bitmap);
                                  private function onContentLoadFail(ioe:IOErrorEvent):void{
                                            trace("Image Load Failed");
                                  private function printPixelValue(bmData:BitmapData):void{
                                            var initPixelValue:Number = -1;
                                            //for (var countI:int = 0; countI < bmData.height; countI++) {
                                            var countI:int = 1;
                                            for (var countJ:int = 0; countJ < bmData.width; countJ++) {
                                                      var pixelValue:Number = bmData.getPixel32(countJ, countI);
                                                      if(pixelValue != initPixelValue){
                                                                initPixelValue = pixelValue;
                                                                // Print the pixel value only for one row
                                                                trace("Pixel Value at " + countI + "x" + countJ + " is: " + pixelValue);
                                            trace("Pixel Value at " + countI + "x" + countJ + " is: " + pixelValue);
                        ]]>
              </fx:Script>
              <s:Button id="loadBtn_ID" label="Load!" click="loadBtn_ClickHandler()"
                                    x="5" y="5" height="20"/>
              <mx:UIComponent id="container_ID" x="5" y="30" width="1366" height="768"/>
    </s:WindowedApplication>
    Sample Image:

    Thanks all,
    Updating the sdk to 4.6.0 fixed the issue

  • ViClose session not called after Read operation Timeout in an IVI COM driver

    Hi everybody
    I have a small VI sample that is initializaing an IVI COM driver for an OPM instrument, set some parameters into the instrument then is doing a single Read power measurement. My Read operation receives a single parameter called MaxTimeout that user could change depending on his own interest. Inside the Read function I change temporarily the VISA query timeout to user timeout but at the end of Read operation the original VISA session timeout is reverted to its original value before Read operation was called. If the Read operation timeout is long enough for the Read operation to complete ( 100 ms or more) the VI is doing its job and when finished the viClose is called twice for DefaultHandler and for OpenHandler.
    If the Read operation timeout value decrease ( 50 ms) then Read operation could not be completed and a Read Operation Timeout error is thrown from inside this method. This error is then propagated trough Error path until the VI end in a Simple Error Handler. Now on my VI I close all open references to my driver interfaces but I don't know why VISA itself is not calling viClose on the DefaultHandler and OpenHandler as in the case when was no VI error. I could see all these diferences in my NI Spy window and I could post this if that could be of any help. Bear with me cause I am more a C, C++, VB programmer and much less of a LabVIEW programmer. BTW the Error Handling from LabVIEW looks a a little weird and the only sure thing is that I wired in Error In and Error Out path in all my VI calls. What kind of error handling should I perform on the Read method in order for VISA to close properly both OpenHandlers even if there is an error in my VI?
    Thansk
    sorinvalea

    So viClose is not called by VISA after an error takes place in a VI that is calling some operations on an IVI COM driver.
    I discovered that all VI sessions opened trough VI that encountered a timeout error in Read operation and that were not properly closed after VI completed are in fact viClose by the LabView itself when I am closing LabVIEW application.
    So these left over open vi sessions are kept aside by LabVIEW until it closes itself and then clean them one by one by calling viClose on them....

  • Retaining leading zero after sum operation

    I have a variable g = 00000005. Now when I am adding g = g + 1.
    The result is coming 6 but without leading zeroes.How could I retain leading zero after sum operation.

    Hi Priya,
    Declare the g as type N.. then do sum.. okay..
    ex :
    data : d(7) type n value '0000005'.
      g = g + 1.
    write : g.
    output is : 0000006.
    Raghunath.S

  • Opening tiff image file and finding pixel values at each point

    I want to open a tiff image file using java.Than i want to find out the pixel values at each point.Also if possible red,green and blue values.
    please mail me answer or code if possible on mail id:
    [email protected]

    Use Java Advanced Imaging to open the Tiff. There is
    a tutorial on it. Look to the left for tutorials, look
    for JAI, do what it says.
    For getting the pixels, do this:
    Use a PixelGrabber to get pixels in array:
    int[] pixels = new int[w * h];
    PixelGrabber pg = new PixelGrabber(img, x, y, w, h, pixels, 0, w);
    pg.grabPixels();
    Use a MouseMotionListner for
    mouseMoved(MouseEvent moueEvent)
    pixel = pixels[mouseEvent.getX() + (mouseEvent.getY()*width)]
    int alpha = (pixel >> 24) & 0xff;
    int red = (pixel >> 16) & 0xff;
    int green = (pixel >> 8) & 0xff;
    int blue = (pixel ) & 0xff;
    Look up the API for MouseMotionListener, PixelGrabber, etc...

  • Compute pixel value statistics on areas delimited by non-rectangular pols

    Hi,
    I'm new with Oracle Spatial/GeoRaster. I'd like to compute pixel value statistics on a GeoRaster object, but I don't want to do it using rectangular polygons (required by SDO_GEOR.generateStatistics procedure). SDO_GEOR.subset procedure uses a rectangular windows or the MBR of a polygon to perform the operations too.
    Is there any way of doing it, or should I have to code myself? BTW, I'm using Oracle GeoRaster 11gR1.
    Thanks in advance,
    Jorge

    Hello Jeffrey,
    Thanks for response. I've tried a different thing. The windows I wanted to use, was a buffer around a point, but I can create the mbr of this buffer, to have a rectangular window. Looking at the result in OpenJUMP, seems to work fine.
    BTW, this is only a small part of my code, and I'm not sure of doing things well. My point is I have 2 layers: a raster layer (loaded as GeoRaster objects) and a vector layer (a shapefile loaded in Spatial). Both in same reference system (srid 4326).
    My vector layer is a set of points, and I've created the mentioned buffers around them. Now, I want to compute pixel value statistics using the MBR of the buffers as window for generateStatistics function.
    georaster table with fields: image_id number, image sdo_georaster
    buffers table with fields: id number, geom sdo_geometry
    The relevant part of my PL/SQL code looks like this:
    declare
    cellCoordinate mdsys.sdo_geometry;
    begin
    for intersection in
         (select t.id, t.geom, r.image_id as rid, r.image from georaster_table r, buffers_table t
         where sdo_geom.sdo_intersection(r.image.spatialExtent, t.geom, 0.005) is not null)
         loop
    -- First, we need buffer geom coordinates in raster space coordinates
    sdo_geor.getCellCoordinate(intersection.image, 0, intersection.geom, cellCoordinate);
    -- Generate statistics for the intersection between georaster spatial extent and buffer, without histogram, layer 1.
    ret := sdo_geor.generateStatistics(intersection.image, 'samplingFactor=1', cellCoordinate, 'FALSE', '1-1');
    -- Insert the statistics array in another table, with the georaster id and the buffer id, to further study
    insert into statistics_table(id, rid, statistics) values (intersection.id, intersection.rid, ret);
         end loop;
    end;
    Could it be a good way of doing this operation?
    Many thanks again

  • When i open my computer I get the white screen with apple symbol and there are vertical lines all over the screen with green pixels and after a few minutes the screen gets grey and I get message to restart my computer what happens

    3 years ago I bought an IMac Desktop that I am using for a lot of things but the most important for dvd montage in Imovies and Idvd.
    Now today when I opened my computer I get as usual the white screen with the Apple symbol but there were all over the screen vertical lines with green pixels and after a while the screen gets grey and I get message to restart my computer using the power button or the restart button and when I do so each time the same is happening somebody can tell me what is happening and what caused this. This computer is my work and now I have no income anymore.
    On the Apple support site they are asking to enter the serial number and when I do so I get message it is wrong but it is the only one I have and I buy this computer in Cairo Egypt. I am living in Hurghada in Egypt for the moment. When I call the technical support of the shop where I buy it they are telling me that it is the hard disk or ram and that I probably lost everything on it and they are asking a big amount to repair.
    Can somebody advise me on this matter. Thanks in advance

    You can find the serial number either in About this Mc in the Menu bar under the , or it should be on a sticker under the foot of the machine.
    If you have the install discs, try booting from them, holding down the c key and then using Disk Utility to check the drive. 
    You can also boot into Safe mode
    To start up into Safe Mode (to "Safe Boot"), do this:
       1. Be sure the computer is shut down.
       2. Press the power button.
       3. Immediately after you hear the startup tone, press and hold the Shift key.
          Tip: The Shift key should be held as soon as possible after the startup tone but not before.
       4. Release the Shift key when you see the gray Apple and progress indicator (looks like a spinning gear).
    During the startup in Mac OS X 10.2 through 10.3.9, you will see "Safe Boot" on the Mac OS X startup screen.
    During the startup in Mac OS X 10.4 or later, you will see "Safe Boot" on the login window, which appears even if you normally log in automatically.
    Please post back with results,
    To leave Safe Mode in any version of Mac OS X, restart the computer normally, without holding any keys during startup.

  • Calculation of Depreciation on Net Book Value after posting Revaluation on

    How to calculate the depreciation on Net book value after posting Balance sheet revaluation ABAW? The depreciation is been calculated on APC and not on NBV, as the APC of asset has been revalued after the revalution posting, ideally the next period depreciation should be calculating on the new NBV, but the system is not doing this. Is there any specific configuration that Iam missing here.
    Kindly Reply.
    Jyoti

    The forum [FPM - General|Enterprise Performance Management (SAP EPM); in which you originally posted your question deals mainly with the financial performance applications otherwise known as Enterprise Performance Management (EPM) carrying the BusinessObjects brand.   Your question pertains to SAP [ERP Financials - Asset Accounting|SAP ERP Financials  - Asset Accounting; which is covered by another forum.  Therefore your message has been moved.  Please adjust any bookmarks you might have and post to the appropriate area in the future, that way you are assured you will have the right audience reading your posts.
    Thanks and best regards,
    [Jeffrey Holdeman|http://wiki.sdn.sap.com/wiki/display/profile/Jeffrey+Holdeman]
    SAP Labs, LLC
    BusinessObjects Division
    Americas Customer Solutions Adoption (CSA) team

  • How Can i retain the Shared Variable Values after PC rebooting

    Hi all,
    I am facing a paculiar problem with Shared Variables. I have an application in which shared variables are used for data communication.
    One of the application requirement is to retain the variable values eventhough PC is rebooted or started after crashing. 
    As per the my understanding, the variable values will retain eventhough the PC is rebooted. But here i can observe a paculiar problem like some library variables are retaing the values while some others not. I enabled logging for all the variables.
    I tried many ways. like logging enabled, logging disabled, changing variable names, changing process names etc... But i am not getting a consistent behaviour.
    I hope some you can help me in solving this issue.. "How Can i retain the Shared Variable Values after PC rebooting"
    Thanks and Regards,
    Mir

    Hi Blackperl,
    Thanks for the post and I hope your well. 
    What do you mean by not getting consistent behaviour.. this will all depend on excatly when the crash happens i.e. before the write or after. 
    Surely a better method would be to log the data to a file during the reboot...
    I beleived the value read back
    will be the default value for the shared variable's data type.
    The LabVIEW DSC 8.0 module adds more functionality to the shared variable, including initial values and alarms.
    If you enable an initial value on a shared variable, when the variable
    engine comes back on-line it will default to this value. Setting a bad
    status alarm for the shared variable is also a good way of handling
    this type of event. Additionally, if you are using a LabVIEW Real-Time
    target such as Compact RIO or Compact FieldPoint, it is appropriate to
    consider hosting the shared variable engine on the real-time target.
    These devices have watch-dog capabilities and are typically the
    hardware controlling the critical pieces of an application. Most
    Windows or PC-based targets do not have these fail-safes.
    I guess, if you could explain to me again that would be great. From my point of view, if I have a cRIO and a Windows PC. If the windows PC crashes, the cRIO will still update its shared variables. Then once the PC has started up its own shared variable engine, and the bindings are loaded, it will once again continue to update its copies of the variables.
    Please let me know what you think,
    Kind Regards,
    James.
    Kind Regards
    James Hillman
    Applications Engineer 2008 to 2009 National Instruments UK & Ireland
    Loughborough University UK - 2006 to 2011
    Remember Kudos those who help!

  • PRODUCTION ORDER--Qty changed after one operation----URGENT

    Dear Experts
            Hope u all R doing well
    In the production order,after one operation completed(whether it is first ,second  or last ) the system is allowing to change the qty.
    but we want the system to disallow  the qty change.
    could anybody can help, is there any configuration settings inside?
    waiting for your valuable response
    Thanks in advance

    Hi,
    Sorry for the delay.
    Pl. follow the steps below.
    1. Create a status profile Eg: s1 usng t.code bs02.
    2. Enter status no. as 1, status as CRTD, a description, tick Initial status & lower status no. as 1 & higher status no. as 2.
    3.In the second line enter status no. as 2, status as REL, a description,  & lower status no. as 1 & higher status no. as 3.
    4.Choose Object type tab.
    5. Choose PP/PM: Order header.(tick)
    6.Then come back to main screen & double click REL.
    7.Click the create icon in the top.
    8.Choose Release & then choose radio button under <b>SET.</b>
    9.Then come back to main screen & again double click REL & then choose create & select change & check the radio button under <b>FORBID</b> & then save.
    10. In t.code OPJH(order type), choose your order type & then assign the status profile( Eg:S1)
    11.Now convert the planned order into production order.Release the order & save.
    Further changes cannot be made in the production order.
    Pl. give feedback after testing.
    Regards,
    S.D.Senthilkumar

  • Resizing PNG with Pixel values; Save as artboard name and pixel value

    Hello,
    first off, I have never written a Javascript before and I am attempting to.  I have been reading like mad to wrap my head around the Extendscript Toolkit (ESTK) in CS6.  I see the awesome potential but I am concerned my idea may not be completely possible.  That's why I thought I would ask the experts here.
    I have a client who needs cursors and icons for apps that are saved out in multiple, transparent PNG sizes and the output filename needs to reflect that name. So for example, I have 2 square artboards, one contains a red car, the other contains the same car but in green, and I want to save both of those as 96x96 pixels, 72 x72 pixels, 48x48, 36x36, and 24x24 (5 different sizes).  I would like the naming scheme to be taken from the artboard name (car_red, car_green) and the pixel value of each size, so the final name would be "car_red_0096x96.png", "car_red_0072x72.png", etc., etc.
    The first thing I noticed is that there seems to be no SaveforWeb object in the ESTK.  I discovered ExportOptionsPNG24 which is nice, but it seems to only give a sizing property based on percent (horizontalScale, or verticalScale).  I would like to use the script to make any size artboard the exact pixel dimensions I need, and the percentage scaling property will not allow this, so is there a way to enter in pixel values and not percentage scale values?
    This of course leads me to my next question: I was hoping to get the script to, at the press of a button, export the selected artboard to all 5 sizes, with a naming scheme that uses the artbaord name as a prefix and the pixel size as the suffix.  I was hoping to use the pixel value in the code to apply to the suffix
    Is any of this possible?
    Gratefully,
    Dave

    I ran a basic test and this should be close enough for you to tweek… Square artboards are assumed by this snippet… A few comments Inc. to help you…
    #target illustrator
    artboardsToPNGs();
    function artboardsToPNGs() {
              if ( parseFloat( app.version ) < 15 ) { return; } // Its CS4 or above ( has artboards )
              if ( app.documents.length == 0 ) { return; } // No docs so end script
              app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
              var i, j, sizes, png24Opts, doc, dF, artBds, abName, scale, pngFile; // Script variables
              sizes = Array( 96, 72, 48, 36, 24 );
              png24Opts = new ExportOptionsPNG24(); // Options object
              png24Opts.matte = false; // Set the properties
              png24Opts.transparency = true;
              png24Opts.antiAliasing = true;
              png24Opts.artBoardClipping = true;
              png24Opts.saveAsHTML = false;
              doc = app.activeDocument;
              dF = Folder( Folder.desktop + "/AI Artboard PNG's" ); // A folder to save in
              if ( !dF.exists ) dF.create(); // Make folder to save in
              artBds = doc.artboards;
              for ( i = 0; i < artBds.length; i++ ) { // Loop the artboards collection
                        doc.artboards.setActiveArtboardIndex( i ); // Make artboard active one
                        abName = artBds[i].name; // Get name
                        for ( j = 0; j < sizes.length; j++ ) { // Loop the sizes Array
                                  scale = ( sizes[j] / ( artBds[i].artboardRect[2] - artBds[i].artboardRect[0] ) ) * 100; // Use width assumed square
                                  pngFile = File( dF.fsName + '/' + abName + '_00' + sizes[j] + 'x' + sizes[j] + '.png' ); // Concat a name string
                                  png24Opts.horizontalScale = png24Opts.verticalScale = scale; // Set the scales
                                  doc.exportFile( pngFile, ExportType.PNG24 ,png24Opts );
              app.userInteractionLevel = UserInteractionLevel.DISPLAYALERTS;
              alert( 'All done…' );

  • Obtain a real pixel value in the range 0-1 rather then 0-255

    Hey guys, Im Stuck!
    I retrieved pixel values from an using raster but they are given in the range 0-255. However i need them in the range 0-1 for matrix manipulation!
    Any Suggestions, any classes, any methods??
    Could you possibly use ratios:
    e.g. if pixel value is 90, to convert into range [0,1] do:
    90/255 *1=0.35294.........
    please would appreciate anything, thanks :)

    tergino wrote:
    Could you possibly use ratios:
    e.g. if pixel value is 90, to convert into range [0,1] do:
    90/255 *1=0.35294.........sound like good advice. However I suggest you convert to double first
    double blue = (double) blueInt/255;

  • FaceTime and activate after changing operator?

    FaceTime and activate after changing operator?

    I recently changed my Apple ID and, initially hit all sorts of problems (ML & iOS5.1). AppleTV very confused, Calandar duplicating entries on an iPad, but losing them on the Mac (but being correct on iCloud.com).
    The solution ended up being straightforward, if unnecessarily annoying.
    On the Mac - in SysPrefs (iCloud) turn off all syncs and sign out. Delete items from the Mac (in response to the prompt).
    On the iPad - in settings do the same.
    On the ATV - turn off Home Sharing.
    In iTunes - log out of the Apple Store
    Sign out on iCloud.com and sign back in using a @me.com email address (not the Apple ID)
    Reestablish iCloud sync (etc) by signing in using the email address (not the ID).
    It appears that everything collects the new Apple ID using the email address and they all play nicely together again.

  • Manipulating condition value after being returned from IPC

    Hi all,
    How can we manipulate the condition rate data after the value is returned from IPC?
    We tried using CRM_PRICING_I_BADI calling the method CRM_PRICING_I_MERGE. But it did not solve the issue.
    Requirement is to read the data of a particular condition type from a preceedign document and then overwirte the conditon value of condition type in the current transaction with that old value from previous document.
    Can this be achieved without using Java coding and manipulate the value after IPC has returned the conditon value and before it is being presented on GUI?
    Please help me with your suggestions.
    Regards,
    David.

    Hello david,
    You might ned to use the user Exit provided by the Pricing Engine to work this out. this will require Java coding.
    Regards,
    Tanu

  • Several pixel value in one iteration

    Hi,
    I am still very new to labview and I have a timing problem with a while loop.
    I am attaching the VI so that it is easier to understand.
    Basically, I read X and Y voltages (with a PCI card) that correspond to a position in an image (that I load). I then convert those positions into a pixel positions and extract the pixel values in the image .
    I then use those pixel values to write on an analogue output.
    My Problem is the following:
    The "Get Pixel Value .vi"  only works Pixel by Pixel meaning that I can only write 1 value every while loop iteration. This is to slow considering that I need to write at least one sample every one/two microseconds and that the while loop is slower than that (at least I think?...)
    How can I transform this vi so that the while loop converts at least 100 position into 100 pixel values so that I can write at least 100 values in one while loop iteration?
    Thank you very much for your help,
    Best ,
    Renaud

    Thanks a lot for those quick replies !
    Image to array is a good solution but I found a work around with a while loop.
    I understand that I won't have microsecond loops without a FPGA but I should be able to read/write around 1000 samples every loop iteration, correct? Otherwise what is the purpose of a DAQ bord type PXI or PCI to have a sampling frequency of 1 to 2 or even 5 MHz??
    In the attached code however I can't seem to read more then 10 sample every 1 milisecond meaning a sampling rate of 1 sample every 100 microsecond... How can I improve the code? 
    Many thanks,
    Best,
    Renaud
     

Maybe you are looking for