Converting doubles to unsigned shorts for grayscale BufferedImages

I'm generating a slightly random array of doubles for use in defining pixel shades in grayscale BufferedImages, so I need to cast each double into a short so that my future DataBuffer can treat them as unsigned shorts. Right now the double values greater than 2^15 are becoming negative when casted, so how do I store it as unsigned?

Thanks for the reply DrLaszloJamf. I need a Gaussian distribution of pixel shades, and the only Gaussian distribution generation functions I can find return doubles. Unfortunately I don't have time to write my own function to do the same with short values, but as implied by your second remark, I think the DataBuffer is doing with the shorts what I need it to. Thanks very much also for your answer to another post that showed me how to generate a grayscale BufferedImage using a DataBufferUShort in the first place!

Similar Messages

  • How to convert double to unsigned long integer for cRIO analog output?

    All,
    Having issues sending out my arbitrary waveform to my cRIO analog output. My values are doubles and by the time I send them out, they have been converted to U32 values and are all turning out as zeroes. This led me to assume two things: 1) That cRIO analog output can only output integers since the values need to be deployed in the memory first and 2) that I'm missing a step in the conversion process. My values range from 0-8, therefore I don't expect that the simple conversion tool in labview should make everything into zeroes.
    Any help?

    Since we are using the cRIO's FPGA interface, you really should be doing most of this inside of the FPGA.  Use DMA FIFOs to pass your data between your RT and the FPGA (and visa versa).
    On your FPGA, you can have a loop that just reads the analog inputs at whatever loop rate you want.  You just send the data to the RT using a DMA.
    Similarly, use a DMA to send your analog output values to the FPGA.  The FPGA can have another loop that reads the DMA and writes the value to the analog output.  This should be done in the FPGA since you can have the FPGA send out the values at a given (and deterministic) loop rate.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Writing double and unsigned integer to serial port

    Hi all
         I have a basic question.  I am trying to write a double or unsigned intger to serial port.  Is it possible to do so?  If it is he case, how do I do it?
    Thank you very much.
    Best
    Hideya

    Hideya,
    The serial port sends one text character at a time. So you must convert your numeric value to a text or string representation and then send the string.
    LabVIEW has several functions on the String palette for numeric conversions. You must decide how to represent the number as text, floating point or exponential notation, number of significant digits, and other formatting issues. These may be dependent on what will be done with the data after being sent.
    Lynn

  • Converting double to String

    I am looking for a way to convert double to String.
    I think that I have to use wrapper like Double class and use toString(double d), but I am not sure how to do it.
    Since toString() is static method, I do not have to have an instance of the Double class, so I was wondering what's the correct way to do it.
    I need something like this:
    String MyString = new String (String1.concat ( My_doubleNumber.Double.toString() ) );
    Any Suggestions?
    Thanks!!!

    WOW thanks a lot. These are definately better than what I thought of doing originally.
    In case I need to use the wrapper class somewhere else, I am just wondering what would be a proper use of Double and String?

  • Working space settings for Grayscale?

    (Preliminary remark: I'm using the German version of PS, so some items may be called differently in the English version.)
    In the colour settings of PS CS4 I can define a working space for gray scale pictures. What does this setting actually do?
    I know that there is no ICC colour management for grayscale pictures, so what do the dot gain settings do? Do they just darken the display or is there more? What do the gamma settings do? What does "Black&White mean? What does sGray mean? Does Photoshop somehow add ICC profiles to grayscale pictures? If yes, which and what does it do?
    So far I decided to just set "no adjustment". The reasoning is that this should display the true greyscale values on the screen. I then can add dot gain as needed manually as a final step. Does this make sense or am I misunderstanding something?
    Bonus question: What about the spot colour settings? Are they applied to multichannel pictures?

    p_d_f wrote:
    Yes, there really are Grayscale ICC profiles...
    Thank you. After contemplating a bit, I think I've finally understood where my confusion originated. But the more I understand, the more new questions arise.
    So far I've understood that if a picture is to be displayed on an internet site or used in an office application, then I best work with the gamma 2.2 profile. If the target computer honours ICC profiles, then it desn't matter anyway which profile I use, but if the target computer ignores ICC profiles, then most computers out there will display the picture with a gamma of 2.2 (more or less) because this tends to be the default setting on most computers.
    But when it comes to pictures for print, some questions remain.
    To begin with, I could continue to work as I did without colour management. I would first "convert" the picture to the profile "no corrections". This would mean that "the numbers" in the picture are the same as the gray values the final user should see. And then I would account for dot gain by either applying a gradation curve or by saving as EPS with a transfer curve.
    However if I want to use colour management, then I "convert" the picture to the the printer's ICC profile. Without a specialized program, I cannot create such a profile myself, even if I know the transfer curve. So either I find a suitable profile somewhere or the print shop must provide me that profile.
    So far I think I understand. But now the questions.
    Concerning missing profiles: Can I just take the gray channel of a suitable CMYK profile (e.g. ISO Coated v2) or would this contain some sort of black generation information which would spoil a grayscale picture?
    I assume that it's possible to embed the black and white point into the profile, so that I don't have to worry about them anymore but can assign the full range of gray values from 0% to 100%. With the colour sync tool, I looked into the grayscale profiles that come with Photoshop, and as far as I can tell, none of them does set the black and white point. So I assume that despite using colour management, I have to do this by hand in the picture itself by assigning appropriate grayscale values?
    If I find a profile which does set the black and white point, then I assume that this is done lossless when I set the intent to "photographic", but when I set the intent to "colorimetrc", then the shadows and lights are just clipped (which jeopardizes the idea)?
    I see that the profiles contain a intent. I assume that this embedded intent will be overridden by the colour setting in photoshop?
    What does the option "blackpoint compensation" (or similiar, I use the German photoshop) do with grayscale images? Does it alter the black point, so I should turn the potion off off when I set it by hand? Is there some documentation what this option *exactly* does?
    The colour settings in Photoshop offers "dot gain xx%" settings, but I didn't find such profiles. Do I assume correctly that those are "internal" profiles of photohop? Are they documented somewhere?
    Thanks.

  • How to specify in TS unsigned long? unsigned short?

    Hi,
    I'm lusing a c/c++ step type from TestStand.
    I need to use a structure whose fields according to the h file of the dll are:
    unsigned char
    unsigned long
    unsigned short
    Now, when I define a container in TestStand (to interface with the dll structure) my options are:
    integer
    unsigned integer
    etc...
    What am I supposed to do ?  what is the appropriate numeric format? 
    Thanks

    Hi Doug,
    I'm given the dll and load of h files.  The definitions you mentioned are not shown...
    Suppose I want to creat in TS a container to match variable FCPortConfig.  This variable structure is given here....
    typedef struct tagFCPortConfig
     unsigned char  ucTopology;    /* For Point-To-Point use TOPOLOGY_PT_2_PT
                  and for LOOP Topology use TOPOLOGY_LOOP */
     unsigned char  ucSpeed;     /* SPEED_1GHZ, SPEED_2GHZ       */
     unsigned char  ucDisableTimer;  /* (Not Currently Used) enable or disable
                  timeout timer          */
     unsigned long  ulRRDYGap;    /* (Not Currently Used) up to a 27-bit val */
     unsigned long  ulRRDYGapRandomEnable;/* (Not Currently Used)enable/disable   */
     unsigned long  ulRRDYGapSeed;   /* (Not Currently Used) If random set;
                  a 27-bit val          */
     unsigned long  ulRRDYGapMin;   /* (Not Currently Used) If random set;
                  a 27-bit val          */
     unsigned long  ulRRDYGapMax;   /* (Not Currently Used) If random set;
                  a 27-bit val          */
     unsigned char  ucAutoNegotiate;  /* (Not Currently Used) enable or disable
                  auto negotiation         */
     unsigned short uiBBCreditConfigRx; /* BB_credit this port will advertise   */
     unsigned char  ucStatsMode;   /* Determines weather or not to retrieve
                                              the extended stats counters, use
                                              STATS_MODE_NORMAL & STATS_MODE_EXTENDED */
     unsigned char  ucReserved[15];  /* Reserved */
    } FCPortConfig;
    1) Is there a way to find out how they define unsigned char, unsigned short and unsigned long?
    2) Can I still use the TS default numeric type?
    Thanks
    Rafi

  • TA25521 After editing a video clip that was shot in 60fps how do I convert that clip to 24fps for publishing

    After editing a video clip in FCX that was shot in 60fps how do I convert that clip to 24fps for publishing?

    There is only a limited amount of Compressor instruction available unless you purchase a subscription to something like Lynda.com or a tutorial from Ripple or Larry Jordan.
    My advice to everyone who is interested in learning about Compressor is to read the first two chapters of the user manual – on basics and workflows. Those should provide enough of an understanding to cover the majority of things users need Compressor to accomplish. Of course there is plenty more for those who want to explore.
    Here is a short write-up from Ken Stone on changing frame rates.
    Good luck.
    Russ

  • Plugin to convert current page from bitonal to grayscale

    I'm scanning pages in which a few percent include a monochrome halftone image. The image quality is not critical, so if I could just convert the page from bitonal to grayscale, the CVision compressor will handle the de-halftoning and produce an acceptable image. I can do this manually with the TouchUp Object tool / Edit Image and convert the mode to grayscale in Photoshop, but that's too tedious. Is there a plugin or some automated way to do this with one click?

    Yes, but I need it to be on a per-page basis, not the whole document. Thus the posting title "convert current page," not convert document. Pdfcompressor's speed is proportional to file size, so making the whole document grayscale defeats the purpose since I want to take advantage of the speed of bitonal and compression of JBIG2, except for those few pages per volume that have halftones. I could also just set the scanner to produce a grayscale file, but that slows down the scanning too. Thank you for trying anyway, and I'm still hoping for a solution.

  • Convert double to Date

    hi everyone, i need to convert a double to a Date. for example 39080.0 is 29/12/2006. could anyone help me??? thanks

    As I recall Excell dates are number of days since 1-1-1900, except that they mistakenly took 1900 to be a leap year, which it wasn't, making them 1 too low.
    Now java dates are based on the number of milliseconds since 1/1/1970. So all you should need to do is to add one, multiply them by the number of milliseconds in a day, and add them to the epoch date of 1/1/1900 (which will be a large negative number which you can calculate with Calendar).
    Suggest you cast to long first.
    ps. One caveat: When doing this kind of calculation DST (Daylight Saving time) can trip you up. Because 1/1/1900 was outside of DST periods if you do these sums and the resultant date is inside the DST periods you are likely to wind up with 23:00 of the previous day - for safety add a couple of hours, load the result into Calendar, then set the time portion of the Date to zero.
    Edited by: malcolmmc on Nov 23, 2007 3:03 PM

  • Convert Double to double

    How can I convert Double to double???

    It's an extremely important skill to learn to read the API and become familiar with the tools you will use to program Java. Java has an extensive set of documentation that you can even download for your convenience. These "javadocs" are indexed and categorized so you can quickly look up any class or method. Take the time to consult this resource whenever you have a question - you'll find they typically contain very detailed descriptions and possibly some code examples.
    Java� API Specifications
    Java� 1.5 JDK Javadocs

  • Deactivate the double click/ hot spot for a particular row in alv grid.

    Hello,
       As per a certain condition how to deactivate the double click/ hot spot for a particular row in alv grid.
    Regards,
    Saroj

    where u define layout there is a field hotspot.like
    data: var.
    if con is true
    var = 'X'. (show hotspot)
    else.
    var = ' '. (deactive hotspot)
    elseif ws_fieldcat-fieldname = 'DMBTR'
                    AND ws_fieldcat-tabname = 'T_MTAB'.
          ws_fieldcat-do_sum = C_X.
          <b>ws_fieldcat-hotsopts = var.</b>
          MODIFY Wt_fieldcat FROM ws_fieldcat
                  TRANSPORTING   DO_SUM.
    It is helpful for u. if any problen send me ur coding i will change it.
    Regards
    Manish Kumar

  • I have upgraded to an Iphone 6 and am at IOS 8.2.  My calendar alerts no longer show up as notifications on my phone.  I have gone into settings and double checked that notifications for calendar was on and it is. Any ideas on a fix?

    I have upgraded to an Iphone 6 and am at IOS 8.2.  My calendar alerts no longer show up as notifications on my phone.  I have gone into settings and double checked that notifications for calendar was on and it is. Any ideas on a fix?

    I have iPhone 4s but the same problem with calendar on 8.2 iOS - no sound, no notification appears - but everything is switched on.

  • How to double space in Pages for iPad?

    How to double space in Pages for iPad?

    Double spacing is double spacing whether you are using Pages or Word. Double spacing is dependent upon the font size that you are using in the document no matter which word processing app that you use.
    Pages on the iPad has limited fonts and chances are pretty good that if you import a Word file into Pages on the iPad, there will be some formatting or font issues.
    But once again, Helvetica in Pages is pretty much the same Helvetica as you would be using in Word. If you use a font in Word that is not available in Pages, you will see a warning message that some elements of the original document have been changed.

  • How to convert exponential data into number for the downloaded excelsheet

    Hi
    I have downloaded one field data i.e. having char of 50,  into excel sheet and it is displaying as  exponential in the excel sheet. 
    The data numbers should display as text only i.e 1236547896321 and not exponential
    Is anyone can tell how we can do this
    Thanks
    Pallavi

    Hello Pallvai,
    The problem of exponential is with the excel. Excel converts the large numbet into exponential.
    To avoid this you can make the number into text then excel won't convert it into exponential.
    For that you can do a simple trick. Just prefix a single quote ( ' ) in the field.
    eg:
    field = 1236547896321.
    then,
    constants c_quote type c value '''.   "<-- single quote
    concatenate c_quote field into field.
    " This will make the EXCEL to consider this field as text not number and hence it will not be considered
    " as exponential.
    Hope this solves your problem.
    Regards,
    Sachinkumar Mehta

  • What is the best way to query planned orders or work orders for make items and identify the buy component that is short for supply and vice versa?

    What is the best way to query planned orders or work orders for make items and identify the buy component that is short for supply and vice versa?

    What is the best way to query planned orders or work orders for make items and identify the buy component that is short for supply and vice versa?

Maybe you are looking for