Reading grayscale values from saved image
Hi,
I've written several methods that crop, convert to grayscale, histogram equalise and then resize a colour jpeg image for preparing sets of images for a face detection neural network. The next thing I want to do is to write a method that allows me to read that saved grayscale images pixel values back as singular grayscale values from the RGB values that were used to save the jpeg. I used this code to create the 2D array of grayscale pixel values
for (int i = 0; i < imageWidth; i++)
for (int j=0; j <imageHeight; j++)
grayRGB[i][j] = (rgb[i][j] & 0xff000000) | (eqGray[i][j]<<16) | (eqGray[i][j]<<8) | (eqGray[i][j]);
img.setRGB(i, j, grayRGB[i][j]);
}and then used this code to resize the image:
BufferedImage resized = new BufferedImage(20,20,1);
Graphics2D g = resized.createGraphics();
g.drawImage(img, 0, 0, 20, 20, null);
g.dispose();my class gets the RGB values on instantiation as follows:
//get RGB pixel values for image loaded
for (int i = 0; i < imageWidth; i++)
for (int j=0; j <imageHeight; j++)
rgb[i][j]= inputImage.getRGB(i,j);
//perform bitwise shift rgb information values to obtain appropriate values for each colour pixel
r[i][j]= (rgb[i][j] >> 16) &0xff;
g[i][j]= (rgb[i][j] >> 8) &0xff;
b[i][j]= (rgb[i][j]) &0xff;
}Is there a way to get the grayscale values directly from an image that is already converted to grayscale without having to perform the grayscale conversion method again, perhaps using a similar bitwise shift?
Thanks
Nick
answering this myself for those lost souls like i was a while ago:
the answer is very simple when you get to know it :) : use a signed type for your image. this can be achieved by using the Format Operator (javax.media.jai.operator.FormatDescriptor). an example as follows :
BufferedImage bufferedImage= someimage...
ParameterBlock pb = new ParameterBlock();
pb.addSource(bufferedImage);
pb.add(DataBuffer.TYPE_SHORT);
RenderedImage formattedImage =
JAI.create("format", pb, null);
// you may use as well TYPE_DOUBLE or TYPE_FLOATimage could be of any type such as PlanarImage, BufferedImage, RenderedImage etc..
then all you need to do is read your pixel values by using an iterator such as RectIter or RandomIter to access pixel values etc..
San
Similar Messages
-
Problem reading RFC values from IRecordSet !!!!
Hi All,
I am having some problem reading values from IRecordSet. Can not seem to parse the output structure from RFC. AM using connector gateway service to execute BAPI_EXCHRATE_GETCURRENTRATES.
Here is the code,
MappedRecord input = rf.createMappedRecord("input");
input.put("DATE",new String("01011990"));
input.put("DATE_TYPE", new String("V"));
input.put("RATE_TYPE", new String("M"));
MappedRecord output = (MappedRecord) ix.execute(ixspec, input);
Object rs = null;
IRecordSet recSet = null;
Object result = output.get("EXCH_RATE_LIST");
if (result == null) {
response.write("<BR>null");
rs = new String(" ");
} else if (result instanceof IRecordSet) {
IRecordSet irs = (IRecordSet) result;
response.write("<BR>Got some dataaa");
IRecordMetaData rsmd = null;
rsmd = irs.retrieveMetaData();
irs.beforeFirst();
while(irs.next()){
response.write("Row::"+irs.getString("RATE_TYPE")+" "+irs.getString("FROM_CURR")+" "+irs.getString("EXCH_RATE"));
Am getting the pritn statement, Got Some Data on the PDK component.
But somehow not able to read the values from IRecordSet
What is the mistake here?
Pls help
Edited by: Aakash Jain on Oct 11, 2008 12:22 AMHi
Try in this way.
IRecordSet resultTable = (IRecordSet)outputParams.get("TABLE_NAME");
for(resultTable.beforeFirst(); resultTable.next(); ) {
response.write(resultTable.getString(0));
response.write(resultTable.getString(1));
Thanks -
Reading any value from table into a string (Especially date etc..)
How would I read any value from a table into a string?
Currently doing the following...
data ret_val type string.
select single (wa_map-qes_field) from z_qekko into ret_val
where
angnr = _angnr.
When the source field is a date it bombs though.
The result goes into a BDCDATA-fval.
regards
Dylan.Tried...
1 DATA: lp_data TYPE REF TO DATA.
2 FIELD-SYMBOLS: <value> TYPE ANY.
3 CREATE DATA lp_data LIKE (wa_map-qes_field).
4 ASSIGN lp_data->* TO <value>.
5 SELECT SINGLE (wa_map-qes_field) FROM zquadrem_qekko INTO <value> WHERE angnr = _angnr.
Complains that (wa_map-qes_field) is not defined in line 3.
Think that the bracket thing is only available via SQL.
What about CREATE DATA lp_data type ref to object. ?
Would the above declaration work?
regards -
How stop PS6 from removing the DPI value from an image when using "save for the web"?
How stop PS6 from removing the DPI-value from an image when using "save for the web"?
Example:
- Open a tif image, that contains a dpi value (resolution).
- Use the splice tool in PS6.
- Export the slices with "Save for web", as gif-files.
Then the dpi value is removed, the gif files has no dpi value (it's empty).
How can we stop PS6 from removing the dpi value when using "save for web"?
OR:
When using the slice tool, how can we save the sliced pieces without PS removing the dpi value?you can make your art go a little bit over the bounds. or you can make sure your artboart and art edges align to pixels
-
Subprocess 33 was not successful. Master cannot read return value from S 33
Hi All,
We are on BI 7.0 SP 19.
We have submitted a planning sequence in the background with automatic packaging.
The planning sequence has two steps:
Step 1. Z_PLNG_FUNCTION1
Step 2. Z_PLNG_FUNCTION2
As per automatic packaging, the system chose 0ACCOUNT for packaging.
When submitted, each step has been submitted to 30 packages as 30 subprocesses.
For Step 1, the log shows that All subprocesses executed.
For Step 2, the log shows that the subprocess 33 and 58 failed, which means subprocess #3, and # 28 for the step 2 as the subprocess is numbered in the log in combination with step 1.
The messages in the log for the failed subprocesses are as follows:
@5C\QError@ Subprocess 33 was not successful
@5C\QError@ Master cannot read return value from subprocess 33
@5C\QError@ Subprocess 58 was not successful
@5C\QError@ Master cannot read return value from subprocess 58
Our question is on how to find the exact cause of the subprocess failure.
I tried to look for the details on the error messages, they have been not helpful.
What is meant by 'Master cannot read return value from subprocess' and how to get the exact cause of the failure?
Thanks in advance,
Best Regards,
- ShashiShashi,
implement the following notes and check again:1368659, 1525723, 1532061.
Regards,
Marc
SAP Techology RIG -
How can I keep people from saving images from my website?
How can I keep people from saving images from my website?
Hi,
have a look at this thread
http://discussions.apple.com/thread.jspa?messageID=5645821&tstart=0#5645821
and the link I posted in that thread
However there's no way to avoid that people grab photos from your website. Nevertheless there are ways for making it a little more difficult.
Regards,
Cédric -
Hi,
a) I want to read EACH VALUE from a spreadsheet file having multiple rows and columns WITH DELAY. I am attaching my VI and sample datalog file for reference (tempsensor.txt).I need to do so because as soon as I read put ON the Sensor button on front panel, LV reads all the values at one go. I need the values for each temperature to be displayed after a delay.
b) Secondly, I would like to read another file containing the state of four antennas (deployed:1; undeployed:0). I am logging state of each antenna in each column of the file(magnet.txt) I need to have four LEDS on front panel to display state of the antennas. I dont know what I have done for antennas in my VI is right or wrong. I guess thats rhe wrong way to approach the problem. Please help!!!(column1: Antenna1 state ; Column2:Antenna2 state.. and so..on..)
Any help would be greatly appreciated!!
Thanks in advance,
Ratnesh
FYI: The first column in my datalog file represents timestamp(number of seconds elapsed), second column: reading for temperature sensor 1, third column: reading for temperature senosr 2, and so on. I am using approx. 11 temperature sensors.
Also, I have generated the log files for the reference purpose only. They do not represent the actual values. They are far away from actual values.
Attachments:
01032005.zip 30 KBLook at this modified version of your VI. After looking at it, I determined that a shift reggister was not required in this case.
Lynn
Attachments:
MultiSensors.2.vi 85 KB -
Hi all :
I try to read Boolean value from xml file , please see attach file , all the time this error rise
I know that The XML tag describing the type of data does not match, how can I get Boolean value " 1" or "0 "
Thanks
wisam
Attachments:
untitled1.JPG 115 KBYou are not trying to read boolean.. you are trying to read a DBL.
To read a DBL you must first write a DBL to XML.
To read a boolean replace the DBL with a boolean -
RE: (forte-users) Reading return value from Javaprogram
when using the RunCommand method you can specify the an error file:
task.part.os.RunCommand(command = l_tdCommandLine,
isSynchronous = TRUE,
inputFile = Nil,
outputFile = Nil,
errorFile = l_ErrorFile.GetLocalName(TRUE));
BEGIN
l_ErrorFile.Open(SP_AM_READ);
EXCEPTION
WHEN Ex: FileResourceException DO
l_ErrorFile = NIL;
task.ErrorMgr.Clear();
END;
IF l_ErrorFile <> NIL THEN
l_tdFileContents : TextData = New();
l_ErrorFile.ReadText(l_tdFileContents);
l_ErrorFile.Close();
END IF;
Have you java program output the return value to the standard IO. This way
you will have an error file that you can read from Forte.
ka
-----Original Message-----
From: Anthony D [mailto:saigonxyahoo.com]
Sent: Tuesday, September 12, 2000 7:49 AM
To: forte-userslists.xpedior.com
Subject: (forte-users) Reading return value from Java program
Hi,
Does anyone know whether Forte application can
read a return value from a Java program?
I'm using the RunCmd method to invoke the Java
program. I'd like to read the return value from the
Java program. How do I go about doing it?
Any suggestion will be appriciated.
Thanks
AD
http://mail.yahoo.com/
For the archives, go to: http://lists.xpedior.com/forte-users and use
the login: forte and the password: archive. To unsubscribe, send in a new
email the word: 'Unsubscribe' to: forte-users-requestlists.xpedior.comwhen using the RunCommand method you can specify the an error file:
task.part.os.RunCommand(command = l_tdCommandLine,
isSynchronous = TRUE,
inputFile = Nil,
outputFile = Nil,
errorFile = l_ErrorFile.GetLocalName(TRUE));
BEGIN
l_ErrorFile.Open(SP_AM_READ);
EXCEPTION
WHEN Ex: FileResourceException DO
l_ErrorFile = NIL;
task.ErrorMgr.Clear();
END;
IF l_ErrorFile <> NIL THEN
l_tdFileContents : TextData = New();
l_ErrorFile.ReadText(l_tdFileContents);
l_ErrorFile.Close();
END IF;
Have you java program output the return value to the standard IO. This way
you will have an error file that you can read from Forte.
ka
-----Original Message-----
From: Anthony D [mailto:saigonxyahoo.com]
Sent: Tuesday, September 12, 2000 7:49 AM
To: forte-userslists.xpedior.com
Subject: (forte-users) Reading return value from Java program
Hi,
Does anyone know whether Forte application can
read a return value from a Java program?
I'm using the RunCmd method to invoke the Java
program. I'd like to read the return value from the
Java program. How do I go about doing it?
Any suggestion will be appriciated.
Thanks
AD
http://mail.yahoo.com/
For the archives, go to: http://lists.xpedior.com/forte-users and use
the login: forte and the password: archive. To unsubscribe, send in a new
email the word: 'Unsubscribe' to: forte-users-requestlists.xpedior.com -
Reading Design values from readback file
Hi All,
I am trying to understand the process of reading back design signal values from readback file.
I have both the .ll file and the readback.bin file
To get the readback file, I executed the below command:
% readback_hw_device [current_hw_device] -readback_file <filename.rbd> -bin_file <filename.bin>
Now, I want to know the command or process to read the design signal values from this .bin file? Is there any command provided by Xilinx or anything else that I can do to read the signal values?
Rgds
Sapan
Hi Syed,
Thanks for the reply. It was actually my own started thread. I had few questions unanswered from that post:
Question:
The procedure for readback that I am following here is based on the ug908-vivado programming and debugging.
I first uploaded the image on FPGA and then I executed the following commands in Vivado Hardware Manager
% create_hw_bitstream -hw_device [current_hw_device] -mask fpga.msk fpga.bit
% verify_hw_devices [current_hw_device] #### For readback verify
readback_hw_device [current_hw_device] -readback_file <filename.rbd> -bin_file <filename.bin> #####for readback capture
This looks a little different from the one suggested in your document. Can you please confirm if my steps are correct?
Using the above procedure, I did not have to explicitly send readback commands to the FPGA using JTAG as mentioned in doc:
http://www.xilinx.com/support/documentation/sw_manuals/xilinx2015_1/ug908-vivado-programming-debugging.pdf
However the other doc http://www.xilinx.com/support/documentation/application_notes/xapp1230-configuration-readback-capture.pdf mentions sending commands to the device in order to be able to do a readback.
So I am a little confused which one is correct?
Also which document will give the words per frame information for FPGA XC7VX485TFFG1761?
Rgds
Sapan
-
How to read enumerated values from an OPC server via Datasocket
Hi Labviewers,
I am using LV8.2 and I am trying to find if it is possible to read enumerations from an OPC server via Datasocket, not just the values.
I can successfully read a value for an OPC server via Datasocket and I get a value for example 3, is it possible to get the enumeration/string that corresponds to this value i.e. "Open".
Many thanks in advance
DimitrisHi Sarah,
With the input type as variant I get the following response:
1 <-This is the current numeric value of the parameter
4 Attribute(s):
'Quality' -> 192
'TimeHigh' -> 29861723
'TimeLow' -> -665408304
'Timestamp' -> 39.238E+3
With the Input set to Enum constant I get no values or strings coming back. With the Input set to Ring constant I just get the numeric value
Dimitris -
Reading filter values from dtp in routine of transformation
Hello,
I try to read a date from the filter of a dtp and propagate this value during the transformation in a routine. this is my code
DATA:
*Date parameter from DTP
i_calday type /BI0/OICALDAY,
i_date(16) type n.
data: t_filter_values type RSBK_TH_RANGE,
l_filter_values like line of t_filter_values.
t_filter_values = p_r_request->GET_TH_RANGE( ).
* get DTP
LOOP AT t_filter_values into l_filter_values.
move l_filter_values-high to i_date.
EXIT.
ENDLOOP.
I_calday = i_date+8(8).
RESULT = I_CALDAY.
but when dubbing my code t_filter_values is always empty and I do not see the selections from the dtp. please do you have an idea what is wrong?
thanksHello
I found the error thanks to Ghuru Balaji S,
now the code is working:
DATA:
t_filter_values type RSBK_TH_RANGE,
i_filter_values like line of t_filter_values ,
i_calday type /BI0/OICALDAY,
i_date(16) type n.
t_filter_values = P_R_REQUEST->get_TH_RANGE( ).
READ TABLE t_filter_values with KEY
FIELDNM = 'DATEFROM' into i_filter_values.
move i_filter_values-high to i_date.
I_calday = i_date+8(8).
RESULT = I_CALDAY.
problem was that I had other selection in the dtp
Edited by: Margit Schütz on Dec 27, 2010 4:08 PM -
Problem when Reading Multiple values from Arduino to Vb
Hi Mates,
I am getting 4 values from Arduino using Serial.Println statement 4 times. How do I need to receive these values to 4 different variables in VB without using any buttons. We have to serial data received as per my knowledge.
I've written the following code in VB.
Imports System
Imports System.ComponentModel
Imports System.Threading
Imports System.IO.Ports
Public Class Form1
Dim myPort As Array 'COM Ports detected on the system will be stored here
Delegate Sub SetTextCallback(ByVal [text] As String) 'Added to prevent threading errors during receiveing of data
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
SerialPort1.PortName = "COM5" 'Set SerialPort1 to the selected COM port at startup
SerialPort1.BaudRate = 9600 'Set Baud rate to the selected value on
SerialPort1.Open()
'Timer1.Start()
End Sub
Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
ReceivedText(SerialPort1.ReadLine()) 'Automatically called every time a data is received at the serialPort
End Sub
Private Sub ReceivedText(ByVal [text] As String)
'compares the ID of the creating Thread to the ID of the calling Thread
If Me.rtbReceived.InvokeRequired Then
Dim x As New SetTextCallback(AddressOf ReceivedText)
Me.Invoke(x, New Object() {(text)})
Else
Me.rtbReceived.Text &= [text]
End If
End Sub
End Class
How do I need to differentiate the values in ReceivedText function and How can I display those values in 4 text boxes. I am able to display all the values in rtbReceived text box as 100200300400100200300400... So on
Assume values from Arduino are 100, 200, 300 & 400
Your suggestions would be more helpful to complete my project, Thanks in Advance
Thanks,
SanthoshHow do I need to differentiate the values in ReceivedText function and How can I display those values in 4 text boxes. I am able to display all the values in rtbReceived text box as 100200300400100200300400... So on
Assume values from Arduino are 100, 200, 300 & 400
Based on the example you have provided you would simply use the String.Substring function to break the string apart ot every 4 characters.
https://msdn.microsoft.com/en-us/library/aka44szs%28v=vs.110%29.aspx
You could do that in a loop that changes the starting character position from 0 in an increment of 4.
However I suspect that won't work properly, either because there are characters that you are not revealing as a result of the way that you are display your results, or because your data gets out of sync.
If your device sends synchronizing characters (such as an end-of-record byte, or perhaps just a CrLf) then the correct process is to append (not overwite) the text you receive. Use a string, not a text box text property, for this buffer. Then you need
to break apart this buffer by scanning forward until you find a complete message - a record identifier and enough (12?) following characters to create a full sentence. Then break it apart using substrings.
If your device data stream does not include something that marks the beginning or end of a complete transmission then you can still try breaking it apart every four characters, and see how reliable it is. -
I need some syntax help with reading some values from a selected row in an Access form.
My goal: to extract the data from 4 fields in a datasheet row and place them in another form.
My problem: I can only get the field values from the first row of the datasheet.
I have tried using the Form_Click event as the location for the code I've tried. This seems to be the right place, but apparently referring to the desired fields by their names with Me. in front just references the first record in the datasheet, not
the one I've selected.
Should I just read the source form's recordset using the Currentrecord value somehow? I could use some direction on that.
Thank you.
Marj WeirIt's generally considered good forum etiquette to post back a description of the solution which you've reached.
The normal control for a multi-valued field is a combo box rather than a text box, but unless it is necessary for you to use a multi-valued field, i.e. your database is interfacing with SharePoint in the very limited context in which this feature is necessary,
I'd advise that you model the many-to-many relationship type in the time-honoured way by means of a table which resolves the relationship type into two one-to-many relationship types, and use a subform to show the data. You can alternatively use a multi-select
list box or a text box which shows a value list. You'll find examples of all three methods in StudentCourses.zip in my public databases folder at:
https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169
If you have difficulty opening the link copy its text (NB, not the link location) and paste it into your browser's address bar.
Ken Sheridan, Stafford, England -
Child package cannot read param value from parent ssis package
Hi all,
I think I must be crazy !! i have a big problem in my ssis project .
i have more than 40 package one parent and 39 childs
i use configuration method to get variable values from parent to child packages and it work well .. but when i copy my ssis project
to the production server i face the following problem .. childs package didn't read the variables values from the parent package
i revised the configuration many times i can't find any missing !!
any help please ...
Thanks,Do not copy the packages from the projet to the production server, but you must generate the manifest installation including your configuration, and deploy them.
Note : not forget to include the configuration.
To learn more about how to install the package :
Lesson 1:
http://msdn.microsoft.com/en-us/library/ms365332(v=sql.105).aspx
Lesson 2 :
http://msdn.microsoft.com/en-us/library/ms365329(v=sql.105).aspx
Lesson 3 :
http://msdn.microsoft.com/en-us/library/ms365321(v=sql.105).aspx
Maybe you are looking for
-
Can't change string variable values in Flash CS4 Debugger
I'm using the Flash CS4 debugger, and while I can change numeric variable values in the Variables panel, I can't change string variable values. The only characters the fields accept are the numbers 1-9 and the characters "d" and "j". I can paste str
-
Canon UFRII not working with IR C5180
Sadly I spent hours on this issue at a client yesterday with no resolution. Not using UFR but just the Canon PPD I can print fine from all stations (both 10.5 and 10.6). The client needs to be sending department ID's along with the print jobs for acc
-
Good days , the following exception is happening: javax.faces.FacesException at de.mindmatters.faces.lifecycle.RenderResponsePhase.executePhase(RenderResponsePhase.java:53) at de.mindmatters.faces.lifecycle.AbstractPhase.execute(AbstractPhase.java:37
-
Hello, I am trying to create pc of code that will recover an XML document that has some parsing error within. Today we are catching the exception and marking the XML doc as bad one, however, it would be nice to know what child node caused the problem
-
ISE 1.0.4 - platform migration
Does anyone know if you can backup and restore to unlike hardware. I am in a situation where we are working fine with 3355 as admin nodes and policy nodes but need to get more horsepower as we reach the endpoint limit. I will be at right around 13,00